c# - How can I route to localhost:2233/username? -


in mvc 4 trying route http://localhost:22128/username. in route.config

routes.maproute(             name: "default",             url: "{controller}/{action}/{id}",             defaults: new { controller = "home", action = "index", id = urlparameter.optional }         ); 

for need change url format? how can route ? can me solve this? confused on this.

edit

i tried

routes.maproute(             name: "default",             url: "{controller}/{action}/{id}",             defaults: new { controller = "home", action = "index", id = urlparameter.optional }         );          routes.maproute(         "userprofile",         "{username}",         new { controller = "profile", action = "index", username = string.empty }         ); 

but still not finding profile controller in index method.

routes order specific. tried first route registered last.

since default route matches every url 0, 1, 2, or 3 segments no url defined after of lengths work.

so need define userprofile route before default route.

routes.maproute(     "userprofile",     "{username}",     new { controller = "profile", action = "index", username = string.empty } );  routes.maproute(     name: "default",     url: "{controller}/{action}/{id}",     defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -