5

在我的 ASP.Net 网站中,我使用<httpRedirect>Web 配置将 URL 永久重定向到其他位置。
我正在从表中读取 URL 值并使用Response.Redirect( URL );
它重定向到该 URL,它运行良好。
但是现在当我尝试使用以下方法将参数发送到调用页面时:

Response.Redirect("Default.aspx?name=stackoverflow");

<httpRedirect>在 web.config 中调用是Default2.aspx因为 web.config 中的以下代码:

<location path="Default.aspx">
    <system.webServer>
        <httpRedirect enabled="true" destination="Default2.aspx" httpResponseStatus="Permanent" />
    </system.webServer>
</location>

问题是Default2.aspx没有收到任何参数。
请帮忙。

注意:我不能使用会话变量,因为页面内容取决于该参数。

例如,
如果用户在新选项卡中打开另一个页面,Default.aspx?name=MetaStackOverflow会话变量将被替换,如果第一页被刷新,那么Stackoverflow它将显示MetaStackOverflow.

4

1 回答 1

6

不要忘记特殊字符$V$Q 并且exactDestination 必须设置为True。

<location path="Help"> <system.webServer> <httpRedirect enabled="true" destination="/Redirect.aspx$V$Q" httpResponseStatus="Permanent" exactDestination="true" /> </system.webServer> </location>

于 2013-02-11T22:36:10.830 回答