【问题标题】:Is it possible to turn off the canonical hostname URL Rewrite rule from the codebehind?是否可以从代码隐藏中关闭规范的主机名 URL 重写规则?
【发布时间】:2011-04-17 16:39:27
【问题描述】:

我想知道是否可以从 URL Rewrite 2.0 IIS 7.5 模块中关闭规范主机名 URL 重写规则。

我在 IIS 7.5 上进行本地开发。此 URL Rewrite 规则的设置在 web.config 中设置。

这就是我的部署方式:我正在使用 Webdeploy 来发布我的 Web 应用程序。与 VS 2010 一起引入的新 web.config 转换对我来说是没有选择的,因为它存在错误:VS 2010 configuration transformation produces unwanted white space during deployment,并且在 VS2010 SP1 发布之前不会修复。我也不再使用 Web 部署项目,因为 Webdeploy 似乎不适用于 Web 部署项目。因此,我在部署之前手动打开了 web.config 中的重写规则。

如果我现在想在本地调试某些东西,我需要手动关闭规则。

有没有类似这种伪代码的解决方案?

if(Properties.Settings.TurnOffCanonicalHostNameWithLocalHost)
{
  URLRewriteModule["CanonicalHostName"].Enabled = false;
}

【问题讨论】:

    标签: c# asp.net url-rewriting


    【解决方案1】:
     <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
    

    【讨论】:

      猜你喜欢
      • 2011-09-23
      • 2012-03-11
      • 2022-01-02
      • 1970-01-01
      • 2018-09-18
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多