开发者

/Mappings/Index is found but not /Mappings with ASP.NET MVC

Just struggling with a simple issue with ASP.NET MVC. I have a list of views, each 开发者_如何学Cview 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜