目前我在我的 ASP.NET MVC 2 项目中有一个名为“API”的区域,这是不言自明的。
随着我的 Web 应用程序 API 的成熟,我很快需要在我的地址中添加版本号。IE/
代替 :
http://site/API/
我需要
http://site/API/1.0/
http://site/API/1.1/
...
在 ASP.NET MVC (2) 中实现这一目标的最佳实践是什么?
我目前正在尝试使用 Area 调用Api_1_0
并将其 MapRoute 修改为
context.MapRoute(
"Api_1_0_default",
"Api/1.0/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
但显然 URL 中的额外斜杠会导致运行时错误。