ASP.Net MVC Outbound Route Matching Problem When Using ActionLink
- by Godders
Hi there,
Hoping for some help after reading into MVC routing and not coming up with the answer myself.
I have the following routes registered:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
null,
"YourFeedback/Article/{resourceId}",
new { controller = "YourFeedback", action = "Index", contentTypeId = new Guid(ConfigurationManager.AppSettings["ArticleLibraryId"]) });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
I have the following ActionLink in an aspx view:
<%=Html.ActionLink("Your Feedback", "Article", "YourFeedback", new
{
resourceId = Model.ContentId.ResourceId
}, new { @class = "yourFeedback" })%>
My understanding of MVC routing is that this would render a anchor link with href of "/YourFeedback/Article/101" where 101 comes from Model.ContentId.ResourceId.
Yet the anchor link href is rendered as "YourFeedback/Article/resourceId=101".
Any ideas where I'm going wrong?
Thanks in advance.