【发布时间】:2014-08-13 22:19:06
【问题描述】:
我的控制器目前看起来像:
[Jsonp filter]
public class ProductController : Controller
{
public Json GetProduct(string id)
{
Product x;
//code
return Json(x, JsonRequestBehavior.AllowGet);
}
}
我可以得到这样的产品: api/product/getproduct/5
但是,我希望能够像这样访问它: api/product/5
我需要做哪些改变才能做到这一点?
编辑:我实际上正在使用 Jsonp,因为我需要从不同的域调用此 API 并返回一个 json 对象。这可以使用 ApiController 吗?否则有没有办法在不切换到 ApiController 的情况下做到这一点?
【问题讨论】:
标签: c# asp.net asp.net-mvc web asp.net-web-api