开发者

MVC 2 with IIS 6 Problems

开发者 https://www.devze.com 2022-12-25 21:39 出处:网络
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'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", "Inde开发者_JAVA百科x", "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).


If this is asp.net mvc 2 within .NET 4.0 make sure you Allow it under web site extensions.


I followed this walk through for setting up on IIS 6.0 on WIN2K3 and it worked great:

http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx

If found that running it locally through the ASP.NET development server was fine. I did not try to set up the app on my local installation of IIS.


As it turns out, ONE of those tricks worked! (Adding the .mvc extension to IIS). It just didnt work for my machine. When I had a someone else try the site out (connecting to the server) it served it just fine. Once I cleared my cache/cookies/etc it seems to work ok. I still cant get it to work directly on the server (in IIS or otherwise), but that's fine since it will never be run from the server itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消