MVC 2 with IIS 6 Problems

Posted by SlackerCoder on Stack Overflow See other posts from Stack Overflow or by SlackerCoder
Published on 2010-04-08T14:24:53Z Indexed on 2010/04/08 15:53 UTC
Read the original article Hit count: 926

Filed under:
|
|
|

Hey guys,

I'm using IIS 6 on a Windows 2003 Server and I am trying to get an MVC2 project installed on that machine. I am having nightmare-ish problems doing so! I've looked up TONS of references on what to do, and not 1 single one works. (They work for MVC1 projects, as I have a few of those running already using said solutions).

Does anyone have any tips/hints/ideas on what needs to be done for MVC2 projects with IIS 6? I am definitely pulling my hair out over this.

I have tried it on 2 of my dev servers, and both get the same result. The closest I can get to a served page is an error page "Object reference not set to an instance of an object", however, the page has try/catch blocks that are being ignored, so I dont think its running the code on the controller, I think it's saying that the controller is the error. (For the reference, the error in question is directed at the HomeController.cs file).

What I've tried:

  • Wildcard mapping
  • Changing routes to {controller}.mvc
  • Changing routes to {controller}.aspx
  • Adding the .mvc extension to IIS
  • Modifying routes in Global.asax

There's a LOT of code in this project so far, so I will only post the first page(s) that should get served:

MASTER PAGE:

<div class="page">

    <div id="header">
        <div id="title">
            <h1>Meritain RedCard Interface 2.0</h1>
        </div>

        <!--
        This is the main menu. Each security role will have access to certain buttons. 
        -->
        <div id="menucontainer">
            <% if (Session["UserData"] != null)
               { %>
                <% if (/*User Security Checks Out*/)
                   { %>
                    <ul id="menu">
                        <li><%= Html.ActionLink("Home", "Index", "Home")%></li>
                        <li><%= Html.ActionLink("Selection", "Index", "Select", new { area = "Selector" }, null)%></li>
                        <li><%= Html.ActionLink("Audit", "Index", "Audit", new { area = "Auditor" }, null)%></li>
                        <li><%= Html.ActionLink("Setup", "Index", "Setup", new { area = "Setup" }, null)%></li>
                        <li><%= Html.ActionLink("About", "About", "Home")%></li>
                    </ul>
                <% } %>
            <% } %>
        </div>
    </div>

    <div id="main">
        <asp:ContentPlaceHolder ID="MainContent" runat="server" />

        <div id="footer">
        </div>
    </div>
</div>

Default.aspx.cs: [I added this file as a potential solution, since it works with MVC 1]

    protected void Page_Load(object sender, EventArgs e)
    {
        string originalPath = Request.Path;
        HttpContext.Current.RewritePath(Request.ApplicationPath, false);
        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current);
        HttpContext.Current.RewritePath(originalPath, false);
    }

HomeController.cs:

    public ActionResult Index()
    {
        loadApplication();

        ViewData["Message"] = "Welcome to ASP.NET MVC!";

        return View();
    }

    public ActionResult About()
    {
        return View();
    }

    private void loadApplication()
    {
        Session["UserData"] = CreateUserSecurity(HttpContext.User.Identity.Name.ToString());
    }

I did not list the CreateUserSecurity method, but all it does it call the DB using the Username and returns the record in the database that matches the username.

EDIT: Added code and what I've tried so far (as requested).

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about iis6