Web Development & Execution
Derek Wheelden
by Derek Wheelden
share this
?fl
« Back to the Blog

ASP.NET C# AJAX Requests Across Two Domains

01/08/2015
ASP.NET C# AJAX Requests Across Two Domains

I made the first Dirigo blog post of 2015.  Yippee

Cross domain issues got you down?

Do you ever find yourself trying to make AJAX requests across 2 different domains ? Browsers hate it! You may have done this in the past to get around the issue:

 

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <add name="Access-Control-Allow-Origin" value="*" />
        </customHeaders>
    </httpProtocol>
</system.webServer>

 

This is great! Except Safari 8 and iOS8 don’t like it. The good news is I’ve gone to the trouble of spending the day trying to figure out how to make it work. Here’s what you do:

 

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <add name="Access-Control-Allow-Origin" value="*" />
            <add name="Access-Control-Allow-Headers" value="content-type,cache-control,accept-encoding,DNT" />
        </customHeaders>
    </httpProtocol>
</system.webServer>

 

That extra header makes Safari 8 and iOS8 so happy! I don’t know why!

Thanks!

Thank you for contacting us!

We'll be in touch!

Back Home ×