Issue adding new controllers and views

Feb 9, 2009 at 1:45 AM
I am trying to add a new controller and view to the project but I am having some issues. The controller was added  and it is very simple and has one function:

namespace

 

Kigg.Web
{
using DomainObjects;
using Infrastructure;
using Repository;
using Service;

 

 

public class BobExtensionController : BaseController

 

{

 

public ActionResult Index()

 

{

return View("Index",null);
}
}

The view is also very simple and it is created under Views\<controllername>\index.ascx as  follows:

 

<%

@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

 

 

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

 

 

 

<h2>Index</h2>

 

</

 

asp:Content>

 

<

 

asp:Content ID="Content2" ContentPlaceHolderID="HeadPlaceHolder" runat="server">

 

</

 

asp:Content>

 

 

 

 All the entries are added to the web.config. The RegisterRoutes function is also changed and the following line is added:

 

 

 

_routes.MapRoute("BobExtension", "BobExtension", new { controller = "BobExtension", action = "Index" });

 

 

When I run the app and use the url http://localhost/kiggrc1/bobextension, I get an error page with Http error 500.0-Internal server error. Using vista 64 bit/iis7 and there are no other errors anywhere. Am I missing something?

 

Feb 9, 2009 at 1:47 AM
Sorry the view file code is as follows:

<%

@ Page Language="C#" MasterPageFile="~/Views/Shared/SiteTemplate.Master" Inherits="System.Web.Mvc.ViewPage" %>

 

 

<

 

asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

 

 

<h2>Index</h2>

 

</

 

asp:Content>

 

<

 

asp:Content ID="Content2" ContentPlaceHolderID="HeadPlaceHolder" runat="server">

 

</

 

asp:Content>

(it has a master page. Although whether you have a master page or not, I get an error)

 

Coordinator
Feb 9, 2009 at 4:03 AM
Turn off the Cutom Error in web.config and check what wrong.
Feb 9, 2009 at 4:56 AM
Custom errors are off. The error screen is as follows:

<fieldset><legend>Error Summary</legend>

HTTP Error 500.0 - Internal Server Error

The page cannot be displayed because an internal server error has occurred.

</fieldset>
<fieldset><legend>Detailed Error Information</legend>
Module ManagedPipelineHandler
Notification ExecuteRequestHandler
Handler UrlRoutingHandler
Error Code 0x00000000
Requested URL http://localhost/Kiggrc111/BobExtension
Physical Path C:\Projects\kiggrc11copy\v2.x\Web\BobExtension
Logon Method Anonymous
Logon User Anonymous
</fieldset>
<fieldset><legend>Most likely causes:</legend>
  • IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
  • IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
  • IIS was not able to process configuration for the Web site or application.
  • The authenticated user does not have permission to use this DLL.
  • The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
</fieldset>
<fieldset><legend>Things you can try:</legend>
  • Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
  • Check the event logs to see if any additional information was logged.
  • Verify the permissions for the DLL.
  • Install the .NET Extensibility feature if the request is mapped to a managed handler.
  • Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.
</fieldset>
Coordinator
Feb 9, 2009 at 9:46 AM
Remove the ErrorHandler from HttpModules in web.config and try again, it will show you the actual exception.
Feb 9, 2009 at 6:14 PM
Thanks Kazi. I removed the ErrorHandler from the httpmodules section  and modules section (this one was creating problems for me). the problem is solved. I had to pass a ViewData which is derived from BaseViewData to the view, which I was not doing before.