gpt4 book ai didi

asp.net - 通过配置向 Cassini 添加 http header

转载 作者:行者123 更新时间:2023-12-02 12:45:38 24 4
gpt4 key购买 nike

我们的 asp.net 网站当前部署到 IIS7 服务器上。我们通过配置文件设置一些 http header ,如下所示:

<httpProtocol>
<customHeaders>
<remove name="X-UA-Compatible" />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>

这对我自己来说非常有用,因为我在 IIS 下托管我的个人网站。我的同事非常愿意继续使用 Cassini 来获得他的开发经验,这意味着我们的自定义 header 不会被发送。有没有办法告诉卡西尼发送这些 header ?

我不想编写自定义模块来添加此内容,并且我不想在我们网站的每个页面上添加标题。

最佳答案

也许您可以在 Global.asax 中添加预编译器指令,这样它只会在 DEBUG 模式下编译时添加 header :

protected void Application_BeginRequest(object sender, EventArgs e)
{
#if DEBUG
HttpContext.Current.Response.AddHeader("X-UA-Compatible", "IE=EmulateIE7");
#endif
}

生产版本编译将忽略这一点,但继续通过 IIS 中的 web.config 设置添加 header 。

关于asp.net - 通过配置向 Cassini 添加 http header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2403263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com