WCF RESTful Service Cross Domain Access from Web Site Client Side Scripts

I’m working on the WCF RESTful service using VS 2010 IDE, during the study we are told that the API will be deployed in the same domain where the site will host, for eg.

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

Site Hosting: www.site.com

Since, the same API will be consumed by our web sites using client side ajax we planned to deploy in the same domain, so there won’t be cross domain / origin access issues.

But, later there is a change that the same API will be consumed by the iPad, iPhone and Smart TV Apps, since there will be a huge traffic to the API we planned to deploy the API in a separate domain called www.api.com/services.svc its is responding well for all the device apps but, we have problem in web sites since it is a cross domain access from client side. After a search, I found codes to break this cross domain policy in the API as below, by implementing the below code in the Global.asax file Application_BeginRequest() its responding well in Chrome, Firefox & Safari browsers but not in I.E

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 to solve this issue...

Thanks in advance...

Sathish

Answers


As far as I know, IE doesn't allow "*" in

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

Try to specify the domain. You could also refer here: Access-Control-Origin in IE


Need Your Help

Any plans for "do"/Action LINQ operator?

c# linq c#-4.0

Here's a simple method with a foreach loop:

Is it possible to change the color of selected radio button's center circle

html css input webkit radio-button

Is it possible to style the center circle of a selected radio button, at least in webkit browsers…?