Click here to Skip to main content
15,886,026 members

ASP MVC Route Config - The resource cannot be found error

Revision 1
I'm newbie in asp mvc, currently, my demo project structure like this:

C#
Areas -- Comment -- Controller -- HomeController
                               -- ManageController

C#
Controller -- HomeController
          |-- CommentController
                     |____ PostMsg
                     |____ DeleteMsg



When I browsing url like :

C#
http://localhost/Comment/Manage/ --> return view successfully
http://localhost/Comment/PostMsg --> error "The resource cannot be found."


Anyone have any idea why asp mvc doesn't resolve my controller :-(

here is my global.asax.cs route config:

C#
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                    namespaces: new[] { "Demo.Web.Controllers" }
                );


here is my area registration route config:

C#
public override void RegisterArea(AreaRegistrationContext context)
            {
                context.MapRoute(
                    "Comment_default",
                    "Comment/{controller}/{action}/{id}",
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                    new[] { "Demo.Web.Areas.Comment.Controllers" }
                );
            }


Any help would be appreciated :-)
Posted 7-Nov-12 4:27am by Van Hua.
Tags: , , ,