Ian Oxley
Ian Oxley

Reputation: 11056

Getting URL Routing to work with ASP.NET MVC on IIS 7

I am trying to deploy a test ASP.NET MVC site to a site hosted on the Rackspace Cloud (essentially just the default site you get when you create a new ASP.NET MVC Web App in Visual Studio).

ASP.NET MVC does not appear to be installed so I have deployed the System.Web.Mvc.dll to the bin folder.

Now, when I access /Default.aspx I get the Home view. But if I enter /Home I get a 404 Page Not Found (I also get a 404 if I access the /Home/About URL).

I have tried adding the .aspx extension to my routes as defined in Global.asax to see if that made any difference but still got the same 404 error.

Am I right in thinking that I should be able to fix this via the Web.config file?

Thanks

Upvotes: 2

Views: 1669

Answers (1)

Tony Borf
Tony Borf

Reputation: 4660

Did you try adding "Root" to the routes and the .aspx extension?

    routes.MapRoute(
        "Default",
        "{controller}.aspx/{action}/{id}",
        new { action = "Index", id = "" }
    );

    routes.MapRoute(
        "Root",
        "",
        new { controller = "Home", action = "Index", id = "" }
    ); 

Upvotes: 3

Related Questions