.net - ASP.NET mvc4 friendly url -
i strugling creation of url user , seo friendly. have controller helloworld :
public class helloworldcontroller : controller { // // get: /helloworld/ public string index() { return "this <b>default</b> action..."; } // // get: /helloworld/welcome/ public string welcome(string name, int numtimes = 1) { return httputility.htmlencode("hello " + name + ", numtimes is: " + numtimes); } } action welcome needs parameters passed
localhost:46963/helloworld/welcome?name=marek&numtimes=5
i want ask how possible pass parameters user friendly url example:
localhost:46963/helloworld/welcome/marek/5
. alerady tryed som magic routes nothing working.
thank in advance.
just write route yourself
routes.maproute( "default", "{controller}/{action}/{name}/{id}", new { controller = "helloworldcontroller", action = "welcome", name = urlparameter.optional,id=urlparameter.optional } ); the params mapped accordingly; these called seo friendly url's
Comments
Post a Comment