none
ASP.Net Web API cross domain function call in Win10 throws error RRS feed

  • Question

  • I have developed ASP.Net Web API application on Win 2012 Server with Win 7 Client & IE 11. Everything seems fine until we upgraded to Win10 with Edge and IE11.

    Making cross domain service call request results in this error:

    Origin "" not found in Access-Control-Allow-Origin Header
    HTTP 401: DENIED - The requested resource requires user authentication

    Global.asa

      if (Context.Request.Path.Contains("api/") && Context.Request.HttpMethod == "OPTIONS")
                {

                    Context.Response.AddHeader("Access-Control-Allow-Origin", Context.Request.Headers["Origin"]);
                    Context.Response.AddHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
                    Context.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
                    Context.Response.AddHeader("Access-Control-Allow-Credentials", "true");
                    Context.Response.End();
                }

    Ajax function call looks like this:

    url: ServiceURL,
                type: "POST",
                dataType: 'json',
                data: { '': data },
        contentType:"application/json; charset=utf-8",
                cache: false,
                crossDomain: true,
                jsonp : false,
                xhrfields : { withCredentials : true},
                success: function (data) {
                               console.log("Saved changes successfully");
                },

    Not sure some of these have been deprecated in Windows 10 with Edge/IE 11!

    Any help would be much appreciated.

    • Moved by CoolDadTx Tuesday, February 6, 2018 3:26 PM ASP.NET related
    Tuesday, February 6, 2018 3:02 PM

All replies