0
我想有兩條路線,例如路由:Asp.net mvc。用斜線
和
http://localhost:1227/Category/
斜槓是唯一的區別。
在第一種情況下,我想在其他情況下顯示關於產品的信息。 「產品」和「類別」是某些產品或類別的名稱
是否可以實施?
我的方法:
路線:
routes.MapRoute("category route", "{name2}", new { controller = "test", action = "GoToView2" }, new { name2 = ".*/?" });
routes.MapRoute("product route", "{name}", new { controller = "test", action = "GoToView1"});
控制器:
public class TestController : Controller
{
//
// GET: /Test/
public ActionResult Index()
{
return View();
}
public ActionResult GoToView1(string name)
{
// call to db to get some information about product
return View((object) name);
}
public ActionResult GoToView2(string name2)
{
// call to db to get some information about category
return View((object)name2);
}
}
索引視圖:
......
<br/>
<a href="@Url.Action("GoToView1", new { name = "Prouct"})">Show proudct</a>
<br/>
<a href="@Url.Action("GoToView2", new { name2 = "Category" + "/" })">Show category</a>
......
但我看到只有「GoToView2」被稱爲兩個鏈接。
任何想法如何解決它?
謝謝,