WCF RESTful Service Cross-Domain Website Access Client Scripts

I am working on the WCF RESTful service using the VS 2010 IDE, during the study we are told that the API will be deployed in the same domain where the site will be hosted, for example,

Hosting API: www.site.com/API/services.svc ( where the API is a virtual folder)

Website Hosting: www.site.com

Since the same API will be used by our websites using an ajax on the client side, which we planned to deploy in the same domain, so there will be no problems with access to the cross-domain / source.

But later there will be a change in the fact that the same API will be consumed by iPad, iPhone and Smart TV applications, since for the API API we plan to deploy the API in a separate www domain. api.com/services.svc responds well to all device applications, but we have problems on websites because it is cross-domain access on the client side. After searching, I found codes to break this cross-domain policy in the API, as shown below, by executing the code below in the Global.asax Application_BeginRequest () file, which responds well in Chrome, Firefox, and Safari, but not in IE

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with");
if (HttpContext.Current.Request.HttpMethod.ToUpper() == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("X-DR-Request-Terminated-By", "CrossDomainXhr-OPTIONS");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}

Please help me solve this problem ...

Thanks in advance...

Sathish

+3
source share
1 answer

As far as I know, IE does not allow "*" in

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");  

. :
Access-Control-Origin IE

0

All Articles