Angularjs CHROME显示http响应已取消

Angularjs CHROME显示http响应已取消,angularjs,google-chrome,asp.net-web-api,Angularjs,Google Chrome,Asp.net Web Api,使用Chrome开发者工具。我在请求WEB API资源时获得取消状态。(网络选项卡) 服务器:WEB API 2.1 客户端:$http请求 初始消息将CORS违规称为原因。我在服务器上启用了CORS public static class WebApiConfig { public static void Register(HttpConfiguration config) { //Going camel case in Web API http://fran

使用Chrome开发者工具。我在请求WEB API资源时获得取消状态。(网络选项卡)

服务器:WEB API 2.1 客户端:$http请求

初始消息将CORS违规称为原因。我在服务器上启用了CORS

 public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        //Going camel case in Web API http://frankapi.wordpress.com/2012/09/09/going-camelcase-in-asp-net-mvc-web-api/
        var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
        jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

        // cors support
        var cors = new EnableCorsAttribute( "http://localhost:9168/", "*", "*");
        config.EnableCors();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        // Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable<T> return type.
        // To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
        // For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
        //config.EnableQuerySupport();
    }
}
似乎有很多关于chrome中取消状态的帖子,都有不同的原因。不知道下一步该怎么办。有什么想法吗?

安装一个Nuget软件包“Microsoft.AspNet.WebApi.Cors”(version=“5.1.0”)

在WebApiConfig.cs文件中添加以下行

config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
您还可以在调用ajax之前在js文件中设置此属性

$.support.cors = true;
安装Nuget软件包“Microsoft.AspNet.WebApi.Cors”(version=“5.1.0”)

在WebApiConfig.cs文件中添加以下行

config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
您还可以在调用ajax之前在js文件中设置此属性

$.support.cors = true;

您没有使用
cors
。谢谢您-刚刚看到输入错误。这解决了问题吗?如果是这样的话,你可以把VTC当作离题->打字,或者干脆删除这个问题。不,它没有。错误又出现了。您没有使用
cors
。谢谢您-刚刚看到输入错误。这解决了问题吗?如果是这样的话,你可以把VTC当作离题->打字,或者干脆删除这个问题。不,它没有。错误又回来了。