문제

I'm attempting to set the content-length of my outgoing response headers but my code seems to have no effect on the headers.

    web_op_context.OutgoingResponse.Headers.Set("Content-Type", http_req.content_type);
    web_op_context.OutgoingResponse.Headers.Add("Content-Length", "10");
    web_op_context.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*");
    web_op_context.OutgoingResponse.Headers.Remove("Server");
    web_op_context.OutgoingResponse.Headers.Remove("X-Powered-By");

The line for adding content-length and removing "Server" and "X-Powered-By" seems to not be rendering any change in my outgoing response headers.

도움이 되었습니까?

해결책

The Server and X-Powered By messages are being sent by IIS, not your code. You have to disable them in IIS prevent them from being sent.

다른 팁

The server and Powered by headers are added outside of your code, by the server. I recently had to remove these because they were flagged in a security scan as warnings. Here is the link I used to remove them. Link i used.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top