【发布时间】:2015-12-27 10:31:19
【问题描述】:
我正在使用 mvc Url.Action
<a href="@Url.Action("Index", "Product", new { area = "Product", search = UrlParameter.Optional, categoryId = category.IdCategory })">
我的路由是:-
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" }
);
}
我无法获取映射到此路线的 url。我得到它作为
但是,如果我将操作更改为
@Url.Action("Index", "Product")
我把这个作为 URL
http://localhost/iteric/?action=Index&controller=Product
我无法弄清楚这种行为的原因。刚开始使用.net mvc。请帮我解决一下这个。
【问题讨论】:
标签: asp.net-mvc-4 asp.net-mvc-routing