For some reason, my application does not properly direct my controller method. I have such a link on my web page -
<%= Html.RouteLink("View", "Blog", new { id=(item.BlogId), slug=(item.Slug) }) %>
In global.asax.cs, I have the following routes -
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"MoreBlogs",
"Blog/Page/{page}",
new { controller = "Blog", action = "Index" }
);
routes.MapRoute(
"Blog",
"Blog/View/{id}/{slug}",
new { controller = "Blog", action = "View"}
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Blog", action = "Index", id = UrlParameter.Optional }
);
And then I have a BlogController class that has a method -
public ActionResult View(int id, string slug)
{
... etc.
}
I set a breakpoint in the first line of the View method, but I don't get any hit. I checked with the route debugger for the localhost / Blog / View / 1 / test format and it matched my custom route. All I get is 404 while running, I canβt understand why the route will not send to the view method in my controller - any ideas?
source
share