【问题标题】:Web.config Rewrite Rule causing error "related configuration data for the page is invalid"Web.config Rewrite Rule 导致错误“页面的相关配置数据无效”
【发布时间】:2017-02-11 13:27:19
【问题描述】:

我收到错误消息“无法访问请求的页面,因为该页面的相关配置数据无效。”当我在 WCF 应用程序的 web.config 中使用重写元素时。

<rewrite>
  <rules>
    <rule name="Rewrite Index">
      <match url="myApplicaiton/Healthcheck.aspx" />
      <action type="Redirect" url="HealthCheck.aspx" />
    </rule>
  </rules>
</rewrite>  

如果请求 url 包含“myApplication”http://localhost/myApplication/HealthCheck.aspx,我想要重定向(服务器重定向)。您能否告诉我上述配置中是否有任何问题,并让我知道是否有任何其他方式对 WCF 应用程序 web.config 中的静态文件进行重定向

【问题讨论】:

标签: asp.net asp.net-mvc wcf asp.net-web-api


【解决方案1】:

你需要条件,试试这个格式

<rule name="ruleName">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^myApplicaiton\Healthcheck$" negate="true" />
  </conditions>
  <action type="Redirect" url="HealthCheck.aspx" />
</rule>

【讨论】:

    【解决方案2】:

    你应该在你的 iis 中安装Url Rewrite extension

    https://www.iis.net/downloads/microsoft/url-rewrite

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-10
      • 1970-01-01
      • 2019-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-14
      相关资源
      最近更新 更多