2011-09-15 3 views
0

コマンドラインアプリケーションでWebServiceHostを使用しています。 Webアプリケーションから取得したこのスニペットに相当する処理を行いたいと思います。何か案は ?webservicehostでのインターセプトリクエストの方法

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(); 
    } 
} 

答えて

関連する問題