I want to have two routes, for example:
and
http://localhost:1227/Category/
trailing slash is the only difference.
In first case I want to show information about product in other case about category. "Product" and "Category" are names of some products or categories
Is it possible to implement?
My approach:
Routes:
routes.MapRoute("category route", "{name2}", new { controller = "test", action = "GoToView2" }, new { name2 = ".*/?" });
routes.MapRoute("product route", "{name}", new { controller = "test", action = "GoToView1"});
Controller:
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);
}
}
Index View:
......
<br/>
<a href="@Url.Action("GoToView1", new { name = "Prouct"} )">Show proudct</a>
<br/>
<a href="@Url.Action("GoToView2", new { name2 = "Category" + "/" } )">Show category</a>
......
But I see that only "GoToView2" is called for two link.
Any ideas how to fix it?
Thanks,