title: how intercept requests with webservicehost
body: <p>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 ?</p>
  
  <pre><code>protected void Application_BeginRequest(object sender, EventArgs e)
  {
    EnableCrossDomainAjaxCall();
  }
  
  private void EnableCrossDomainAjaxCall()
  {
    HttpContext.Current.Response.AddHeader("Access-Control-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();
    }
  }
  </code></pre>