I am using mvc Url.Action as this
<a href="@Url.Action("Index", "Product", new { area = "Product", search = UrlParameter.Optional, categoryId = category.IdCategory })">
I have my routing as:-
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Product_default",
"Product/{controller}/{action}/{id}/{categoryId}",
defaults: new { controller = "Product", action = "Index", search = UrlParameter.Optional, categoryId = @"\d+" },
namespaces: new[] { "IBuyFrontEnd.Areas.Product.Controllers" }
);
}
I cannot get the url to map to this route. I am getting it as
However if i change the action to
@Url.Action("Index", "Product")
I get this as Url
http://localhost/iteric/?action=Index&controller=Product
I cannot figure the why so of this behavior. Just started using .net mvc. Please help me with this.
Ok So figured out that to get Url.Action to generate the url requires the that action to be present in the controller, and also the parameters should be in place. So i just changed my controller action to