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");

Please help me to solve this issue...

Thanks in advance...



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

use of lambda in itertools.product for better code

python lambda

To help me better understand and write a bit more compact code, I suspect the following can be written in a one liner joining the two perms = assignments with the use of lambda. Any python guru?

Mockito framework

java spring mockito

I want to test follow method

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.