【发布时间】:2014-03-14 01:04:14
【问题描述】:
我正在使用 asp.net 开发一个 WEB API,我的目标是能够调用这种类型的 url:
/html/countries/...
/json/countries/...
Countries 是一个控制器,根据参数返回不同的结果。
我做了什么,但它似乎不起作用:
routes.MapRoute(
name: "Default",
url: "api/{action}/{controller}",
defaults: new
{
}
);
CountriesController:
[ActionName("html")]
public string get()
{
//...
}
[ActionName("json")]
public void getType()
{
//...
}
有什么建议吗? 编辑: 我有 7 个控制器。
还有一些可能的网址:
/html/{controller}/x/y
/json/{controller}/x/y/order/h
/html/{controller}/x/z/order/y/j
/json/{controller}/x/z/order/y/j
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-web-api routing