2011-08-11 3 views
3

응답 헤더에서 서버 필드를 변경하는 HttpModule이 있습니다. 그러나 그것은 ASP.NET/IIS7 클래식 모드에서는 작동하지 않습니다. 응답 헤더의 서버 필드를 제거하거나 변경하기위한 솔루션은 무엇입니까?ASP.NET/IIS7 클래식 모드에서 HTTP 응답 헤더를 설정할 수 없습니다.

public class CloakHttpHeaderModule : IHttpModule 
{ 
    public void Init(HttpApplication app) 
    { 
     app.PreSendRequestHeaders += new EventHandler(context_PreSendRequestHeaders); 
    } 

    public void Dispose() 
    { 
    } 

    private void context_PreSendRequestHeaders(object sender, EventArgs e) 
    { 
     var context = ((HttpApplication)sender).Context; 
     context.Response.Headers.Set("Server", "Apache 2.0"); 
     //HttpContext.Current.Response.Headers.Set("Server", "WSGIServer/0.1 Python/2.6.1"); 
    } 

} 

답변

5

적어도 IIS7, 통합 파이프 라인 모드 및 .NET 3.0을 실행하지 않는 한이 작업을 수행 할 수 없습니다. 문서 상태이 :

HttpResponse.Headers Property

헤더 속성은 오직 IIS 7.0 통합 파이프 라인 모드를 지원 적어도 .NET 프레임 워크 3.0입니다. 에 Headers 속성에 액세스하려고 시도하고이 두 조건 중 하나라도 충족되지 않으면이 발생하면 PlatformNotSupportedException이 throw됩니다.

관련 문제