I am trying to get a WCF DataService working with cross domain requests. I found this on how to get a WCF service to work with CORS: http://blogs.microsoft.co.il/blogs/idof/archive/2011/07/02/cross-origin-resource-sharing-cors-and-wcf.aspx
I downloaded the sample, but can't get it to work with a DataService. It works with the sample service, but not with my DataService.
This is my very simple WCF DataService:
public class TestService : DataService<DataContext>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("Items", EntitySetRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
}
The TestService.svc file:
<%@ ServiceHost Language="C#" Factory="WebHttpCors.CorsWebServiceHostFactory, WebHttpCors" Service="MvcApplication1.TestService" %>
The DataContext is also very simple:
public class DataContext : DbContext
{
public DbSet<Item> Items { get; set; }
}
But still, the preflight options request returns with a 501. Is there something I am missing to get CORS to work with a Dataservice?