Web API 2 - CORS only works via HTTPS (not HTTP)

All,

I have a really simple Web API 2 project I'm working on. For some reason, I cannot get CORS to work correctly unless I put it in a web.config file. I followed the instructions in the MSDN article , and this is an ASP.NET article , but I have to miss something.

Global.asax.cs

protected void Application_Start()
{
    WebApiConfig.Register(GlobalConfiguration.Configuration);
}

WebApiConfig.cs

public static void Register(HttpConfiguration config)
{
    config.EnableCors(new EnableCorsAttribute("*","*","*"));

    config.MapHttpAttributeRoutes();
}

Javascript

    $.ajax({
        url: '//myapidomain.com/buildings'
    }).done(function (data) {
        var theList     = $('.buildings'),
            theListHTML = "",
            response    = JSON.parse(data);

        $.each(response.Buildings.Data, function () {
            theListHTML += '<li>' + this.Description + '</li>';
        });
        theList.html(theListHTML);
    });

I looked at almost every stack overflow (like this one ) and the MSDN forum post (like this one ), and from what I can tell, this should work. The application is hosted on IIS 8 since 4.0.

Update

, - (, , IIS). HTTP, ( ). , HTTPS, .

, HTTPS, HTTPS. , 304, jQuery- , . , HTTPS () / /, .

+4
1

, HTTPS, HTTPS. , 304, jQuery- , . , HTTPS () / /, .

0

All Articles