我正在努力解决CORS(跨源资源共享)的ASP.Net WEB API 2.0问题。我安装了ASP.Net.Web.API 2.0 CORS软件包并启用了cors.no webdav.defualt webconfig就像这(见http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api) put,get和post work,删除405代码的错误,我该怎么办?
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}