use*_*827 4 asp.net web-config parameter-passing http-redirect
在我的ASP.Net网站中,我使用<httpRedirect>web配置永久地将URL重定向到其他位置.
我正在从表中读取URL值并使用Response.Redirect( URL );
它正确地重定向到该URL .
但是现在当我尝试使用以下命令将参数发送到调用页面时:
Response.Redirect("Default.aspx?name=stackoverflow");
Run Code Online (Sandbox Code Playgroud)
<httpRedirect>在web.config中Default2.aspx因为web.config中的以下代码而调用:
<location path="Default.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="Default2.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)
问题是Default2.aspx没有收到任何参数.
请帮忙.
注意:我不能使用会话变量,因为页面内容取决于该参数.
例如,
如果用户在新选项卡中打开另一个页面,Default.aspx?name=MetaStackOverflow会话变量将被替换,如果第一页被刷新,那么Stackoverflow它将显示而不是显示内容MetaStackOverflow.
小智 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>