2

I am working on a Web Forms Web Application with mixed in MVC. I have followed the instructions from this page http://www.packtpub.com/article/mixing-aspnet-webforms-and-aspnet-mvc and it works fine in VS2010 developer server but when I try to publish it to a MVC enabled IIS 6 browser is not automatically redirect to default.aspx after login and I get a 404 error at the root of the application.

My Global.asax.cs looks like this:

    protected void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
        routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = "" }
        );
    }

If I comment out the call to RegisterRoutes in Application_Start method the automatic redirect to default.aspx works but then the MVC parts fail.

I need some help with how to setup the routing to enable automatic redirect to default.aspx while enabling the MVC routing. The MVC parts is located under a specific path like so: myserver/applicationname/mvcparts.

Asp.Net MVC 3 is installed on both developer machine and server where I publish.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
Martin Larsson
  • 720
  • 2
  • 10
  • 21
  • 1
    A clarification: All direct access to pages with extensions (page.aspx (web forms)) works fine. It is after login that the browser brings up myserver/myApplication and not to myserver/myApplication/default.aspx as it does on my developer machine. This is where I get the 404. When I then update the url to point do default.aspx or som other aspx page all is well. – Martin Larsson Jan 13 '12 at 10:03

1 Answers1

1

That's because IIS6 doesn't support extensionless urls by default. You will need to configure it. And if you are not using ASP.NET 4, this is for you. If you don't configure it; IIS6 doesn't know that /Home/Index must be associated with the aspnet_isapi filter. It doesn't even know that this is an ASP.NET application. That's the reason why in classic WebForms, they used the .aspx extension which is associated with the aspnet_isapi filter when you install .NET.

Extensionless urls are supported by IIS7+ out-of-the-box when running in integrated pipeline mode.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I cant really see a solution to my problem in the link to Haacks blog you provided, what I read there is that it should work. He got a 403 but I get a 404. .Net 4 is installed. In fact my problem is that extentionless urls work in my application but the defaultDocument, default.aspx does not. – Martin Larsson Jan 13 '12 at 09:56
  • @Riddler777, what default document? In an ASP.NET application you normally don't have a default.aspx file. – Darin Dimitrov Jan 13 '12 at 10:37
  • defaultDocument is set in the configuration of the virtual directory in IIS. – Martin Larsson Jan 13 '12 at 11:17
  • @Riddler777, yes I know where is it set. My question was do you have such file `default.aspx` in your ASP.NET MVC application? – Darin Dimitrov Jan 13 '12 at 12:31
  • It is a Web Forms Web Application with MVC under a specific folder (myserver/app/mvcparts). In the root of the application there is a default.aspx, so yes. – Martin Larsson Jan 13 '12 at 12:59