Web.config重写规则导致错误“页面的相关配置数据无效”

时间:2016-10-03 14:46:01

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

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

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

如果请求网址包含“myApplication”http://localhost/myApplication/HealthCheck.aspx,我想要重定向(服务器重定向)。如果在上面的配置中有任何问题,请告诉我,如果有任何其他方式在WCF app web.config中重定向静态文件,请告诉我

2 个答案:

答案 0 :(得分:1)

您应该在iis中安装Url Rewrite extension

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

答案 1 :(得分:0)

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

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