I have an existing ASP.NET 3.5 WebForms project and have added ASP.NET MVC to the project. The existing pages work fine and so do the new controllers & views. However, when I deploy to IIS 7 the default document (default.aspx) is no longer working. I can get to it if I type it in explicitly but 'xyz.com' doesn't work - I get a 404. In contrast, it does work fine in Cassini.
How do I get the default document working again while still retaining the new MVC stuff.
I added the following to the Global.asx.cs
file and the default document works again.
public static void RegisterRoutes(RouteCollection routes)
{
// *** This Line ***
routes.IgnoreRoute(""); // Required for the default document in IIS to work
// *****************
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start(Object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With