You must map this route before all other route mappings (routes are evaluated in order):
routes.MapRoute(
name: "Product", // any name meaningful for you is right
url: "Product/{productName}",
defaults: new { controller = "Product", action = "CategoryLevel" }
);
URL-, :
http:
X. , :
public ActionResult CategoryLevel(string productName)
. : productName
, , :
http:
CategoryLevel, productName "Vitamins"
, List,
http:
CategoryLevel productName= "List"
, :
routes.MapRoute(
name: "Product", // any name meaningful for you is right
url: "ViewProduct/{productName}",
defaults: new { controller = "Product", action = "CategoryLevel" }
);
, . URL-, , :
http:
, .
: , View, CategoryLevel. , :
routes.MapRoute(
name: "ViewProduct", // any name meaningful for you is right
url: "ViewProduct/{productName}",
defaults: new { controller = "Product", action = "View" }
);
:
public ActionResult View(string productName)
URL- , URL- MVC, Html.ActionLink Url.Action. , - :
Url.Action('View', 'Product', new {productName = "Vitamins"} )
URL-:
http:
.. , URL- .