跨源请求被阻止:(原因:CORS预检频道未成功)。在Fifox

时间:2016-03-31 02:42:38

标签: asp.net asp.net-mvc-4 asp.net-web-api

我在visual studio 2010中遇到API MVC 4问题 在客户端,我使用了Ajax:

    $.ajax
    ({
        headers:
                {
                    'Content-Type': 'application/json', 
                    'Access-Control-Allow-Origin':'*',
                    'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
                    'Access-Control-Request-Method':'*',
                    'Access-Control-Allow-Headers':'*',
                    'Accept': 'application/json',
                    'allow-navigation':'*'
                },
        type: "GET",
        url: "http://192.168.1.16:8080/api/Parameter/getGender",
        //contentType: "application/json",
        datatype: "json",
        async: true,
        crossDomain: true,
        success: function successfunc(data)
        {
            alert(data);
        },
        error: function failfunc(data) {
            alert('Error!');
        }

当我在IE浏览器中运行时没问题,但我在firefox浏览器中运行它我看到错误:

"阻止跨源请求:同源策略禁止在http://192.168.1.16:8080/api/Parameter/getGender读取远程资源。 (原因:CORS预检频道没有成功)。"

0 个答案:

没有答案
相关问题