我訪問的WebAPI資源這樣的:爲什麼參數不綁定到WebAPI應用程序?
localhost/myapp/api/values?ParamOne=123&ParamTwo=testing
在ValuesController,我有這樣的:
public class MyParams {
public int? ParamOne {get;set;}
public string ParamTwo {get;set;}
}
[HttpGet]
public HttpResponseMessage Get([FromUri]MyParams someparams) {
...
}
當我嘗試訪問該資源時,我得到這個錯誤:
HTTP Error 403.14 Forbidden The Web server is configured to not list the contents of this directory
下面是RouteConfig.cs,它只是默認值:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {controller="Home", action="Index", id=UrlParameter.Optional}
任何人都知道我在做什麼錯了?
郵政路線配置繼承。 –
剛發佈。我沒有改變RouteConfig。 – 4thSpace
它是api控制器還是mvc控制器?路由配置看起來像mvc config,而uri看起來像api。 –