I'm newbie in asp mvc, currently, my demo project structure like this:
Areas -- Comment -- Controller -- HomeController
-- ManageController
Controller -- HomeController
|-- CommentController
|____ PostMsg
|____ DeleteMsg
Views -- Home
| |--- Index.cshtml
|-- Comment
|--- PostMsg.cshtml
|--- DeleteMsg.cshtml
When I browsing url like :
http:
http:
Anyone have any idea why asp mvc doesn't resolve my controller :-(
here is my global.asax.cs route config:
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:
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" }
);
}
Problem : Comment/PostMsg url was resolved as an Controller in Comment Area
Goal : Comment/PostMsg url was resolved as an Action of CommentController
Any help would be appreciated :-)
ISSUE RESOLVED, edit area registration route config (work around):
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Comment_default",
"Comment/PostMsg",
new { controller = "Comment", action = "PostMsg", id = UrlParameter.Optional },
new[] { "Demo.Web.Controllers" }
);
context.MapRoute(
"Comment_default",
"Comment/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "Demo.Web.Areas.Comment.Controllers" }
);
}