更新时间:2022-12-18 09:28:56
请下面的解决方案尝试。在的global.asax.cs
Please try with below solution. In global.asax.cs
routes.MapRoute(
"Product",
"{productName}",
new { controller = "Product", action = "Index" },
new { productName = UrlParameter.Optional }
);
但您保持独特性在产品名称
,并在产品控制器的索引操作通过获取记录所需(即在产品的控制器:
But you required to maintain uniqueness in productName
and fetch record by that in index action of product controller (i.e in product Controller:
public ActionResult index(string productName)
{
//do something regarding get product by productname
}