【发布时间】:2013-06-05 15:04:03
【问题描述】:
好吧,在我的 C# ASP .Net MVC 应用程序中,我有一个 URL:
controller/action?parameter=value
我需要使用重写规则将 web.config 中的这个 URL 重定向到:
controller/action?parameter=anotherValue
我已经配置了必要的部分,如下所示:
<rule name="Redirect" patternSyntax="Wildcard" stopProcessing="true">
<match url="controller/action?parameter=value" />
<action type="Redirect" url="controller/action?parameter=anotherValue" />
</rule>
但是这条规则是行不通的。我也试过了:
<rule name="Redirect" patternSyntax="Wildcard" stopProcessing="true">
<match url="controller/action$" />
<conditions>
<add input="{QUERY_STRING}" pattern="parameter=value" />
</conditions>
<action type="Redirect" url="controller/action?parameter=anotherValue" redirectType="Permanent" />
但这条规则将我重定向到:controller/action?parameter=value&parameter=anotherValue
如何正确执行此重定向?
【问题讨论】:
标签: c# asp.net-mvc redirect web-config