WebApi工作正常,然后我添加了一些odata控制器,现在我的webapi回复未找到。我假设它在某处的路由中,但我没有看到它。返回404未找到。如何修复我的webapi以返回数据获取。
Global Config
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Web API配置
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}/{action}",
defaults: new { id = RouteParameter.Optional }
);
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<pp_tsr_accounts_tab_Result>("pp_tsr_accounts_tab_Result");
config.Routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());
config.EnableSystemDiagnosticsTracing();
}
呼叫
http://localhost:xxx/api/pp_tsr_offer_calc_Result/Getpp_tsr_offer_calc_Result?id=0801314923
答案 0 :(得分:0)
我赢得了白痴奖。
routeTemplate: "api/{controller}/{action}/{id}",
不是
routeTemplate: "api/{controller}/{id}/{action}",