views:

312

answers:

4

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).

+1  A: 

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.

SlackerCoder
+1  A: 

Hi - 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.

Daryl
This is one of the "tutorials" I followed. This was the winner that actually worked. I think a few of the others would have worked too, but given that I couldnt get ANY to work on my system until I cleared the cache, etc, I could never get anything going!
SlackerCoder
+2  A: 

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

Jack Marchetti
A: 

Hi all,

I have implemented a MVC2 application which is using JQuery Modal windows for update/insert/dete operations. Under the default VS2008 web server everything looks good (modal windows appears and everythings was OK). After I deployed the application to IIS and configure .mvc extensions the WebSite starts (I fetched data from the DB) but the Modal Window which is displaying data for (insert/update/delete)is never showed. I gues the problem is the javascript's path which looks like that: javascript:DoModal('111-111-111',\City\QuickEdit\'111-111-111', 23,12,'Edit') - 111-111-1111 -> means a GUID - the third and forth parameters represent width and height of the modal window since the fifth one represent the caption. I have look in the JS and the problem is when I want to populate the window modal with the results of the partial view. $dialog.get{ url, -> \City\QuickEdit\'111-111-111' ....

I have changed the Global.ascx.cs to use .mvc extensions. How should I solve this problem?

Best Regards

Bogdan Mitrea