how intercept requests with webservicehost
I am using WebServiceHost in a commandline app. I want to do the equivalent of this snippet that I got from a web application. Any ideas ?
protected void Application_BeginRequest(object sender, EventArgs e)
{
EnableCrossDomainAjaxCall();
}
private void EnableCrossDomainAjaxCall()
{
HttpContext.Current.Response.AddHeader("Access-C开发者_开发百科ontrol-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
Like this.
http://dhvik.blogspot.com/2011/06/supporting-cross-origin-resource_9123.html
精彩评论