Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未设置C#-HttpWebResponse标头_C#_Http Headers_Content Length_Weboperationcontext - Fatal编程技术网

未设置C#-HttpWebResponse标头

未设置C#-HttpWebResponse标头,c#,http-headers,content-length,weboperationcontext,C#,Http Headers,Content Length,Weboperationcontext,我试图设置传出响应标题的内容长度,但我的代码似乎对标题没有影响 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-C

我试图设置传出响应标题的内容长度,但我的代码似乎对标题没有影响

    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");

添加内容长度和删除“Server”和“X-Powered-By”的行似乎没有对我的传出响应头进行任何更改

服务器和X-Powered By消息是由IIS发送的,而不是您的代码。您必须在IIS中禁用它们,以防止它们被发送。

服务器和受标题支持的邮件由服务器添加到代码之外。我最近不得不删除它们,因为它们在安全扫描中被标记为警告。这是我用来删除它们的链接

    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");