È possibile aggiungere un percorso al motore di routing MVC in questo modo -
In Global.asax.cs
routes.MapRoute(
"Product",
"{controller}/{productId}/{productName}",
new { controller = "Product", action = "Index" },
new { productId = UrlParameter.Optional , productName = UrlParameter.Optional }
);
Questo vi permetterà di avere URL tipo
www.domain.com/productid/productname
Il motivo si può o non può essere in grado di raggiungere
www.domain.com/productname
è che isn productName' t un identificatore e non può essere usato per cercare un record in modo univoco. Avresti bisogno di un identificatore nell'URL.
Ex - guarda l'URL per questa domanda in SO, ha l'ID e quindi aggiunge il test SEO friendly.
fonte
2013-02-28 06:32:19
http: //ofps.oreilly. it/titles/9781449320317/ch_Routing.html –