开发者

URL routing in mvc

I have this url working in my code:

http://localhost:12345/home/index/<parameter1>/<parameter2>/<parameter3>/<parameter4>

I want to change my url to NOT 开发者_运维问答to include the home/index (<controller>/<action>).

My current Global.asax entry is like:

 routes.MapRoute(
   "Default", // Route name
   "{controller}/{action}/{parameter1}/{parameter2}/{parameter3}/{year}/{parameter4}", // URL with parameters
   new { controller = "Home", action = "Index", parameter1= "", parameter2= "", parameter3= "", parameter4= ""} // Parameter defaults
   );

Please let me know how can i change it thanks in advance


Should be as simple as removing those parameters from the URL since you have them in the Defaults dictionary.

routes.MapRoute( "Default", // Route name "{parameter1}/{parameter2}/{parameter3}/{year}/{parameter4}", // URL with parameters new { controller = "Home", action = "Index", parameter1= "", parameter2= "", parameter3= "", parameter4= ""} // Parameter defaults );

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜