Question

Just struggling with a simple issue with ASP.NET MVC. I have a list of views, each view associated with an Index.aspx view being associated by default with /MyView.

Yet, for some reason I have 1 view named /Mappings that does not work (404 resource is not found) whereas the explicit path /Mappings/Index works.

I have the default route settings as provided by the default ASP.NET MVC sample

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

And, the default Index works for the other views of the same webapp.

Any idea what could be wrong here?

Was it helpful?

Solution

You have to define default action if it is not provided:

route.MapRoute(
            "Default", // Route name
            "{controller}/{action}", // URL with parameters
            new { action = "Index" }  // Default action if not provided
        );

EDIT:

Look at this link:

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

You can use this debugger to test your routing.

OTHER TIPS

Have you set a default action value in your route equals to Index ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top