我想访问以下方法,但我无法访问“ http://www.test.com:46707/rpc/RealmStatus/RealmByPopulationName/2/Vindication ”
[ActionName("RealmByPopulationName")]
public IEnumerable<MyRealmStatus> GetRealmsByBattleGroupName(int regionid, string battlegroupname)
{
//dosomething...
}
我的 webApiConfig.cs 下面
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{regionid}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "GetData",
routeTemplate: "api/{controller}/{regionid}/{id}"
);
config.Routes.MapHttpRoute(
name: "RpcApi",
routeTemplate: "rpc/{controller}/{action}/{regionid}",
defaults: new { action = "Get" }
);
config.Routes.MapHttpRoute(
name: "RpcApi2",
routeTemplate: "rpc/{controller}/{action}/{regionid}/{quality}/",
defaults: new { action = "Get" }
);
config.Routes.MapHttpRoute(
name: "RpcApi3",
routeTemplate: "rpc/{controller}/{action}/{regionid}/{battlegroupname}/",
defaults: new { action = "Get" }
);
}
}
发生错误我无法访问 GetRealmsByBattleGroupName
“ http://www.test.com:46707/rpc/RealmStatus/RealmByPopulationName/2/Vindication ”的结果:
<Error>
未找到与请求 URI ' http://www.test.com:46707/rpc/RealmStatus/RealmByPopulationName/2/Vindication '匹配的 HTTP 资源。在与请求匹配的控制器“RealmStatus”上未找到任何操作。