【发布时间】:2019-08-29 08:05:41
【问题描述】:
在从视图映射到控制器后,我试图隐藏或替换 URL 中的字符串。
查看
<a href='@Url.Action("Product", "Index", new { prodID =@item.ProductID
})'>
控制器
public ActionResult Product()
{
return View(model);
}
现在我在这样的网址中得到这个http://localhost:9210/Index/Product?prodID=1
但我想要url 像这样http://localhost:9210/Index/Product/1
那么我该怎么做呢?请帮忙
【问题讨论】:
-
那么您必须在路由配置中或通过属性定义路由
/Product/{prodID}。 -
是的,没错,我想要这样的`localhost:9210/Index/Product/1
-
@CodeCaster 我该怎么做请告诉我
-
@icon 试试下面的答案。
标签: c# asp.net asp.net-mvc asp.net-mvc-4 routes