![](/img/trans.png)
[英]Response.Redirect not redirecting to a specific URL in ASP.NET MVC
[英]Redirect URL with specific section in it - ASP.NET MVC
我现有一个页面,其中包含几个问题(如常见问题),其网址为
主要帮助URL:sitename.com/特定部分的帮助URL:sitename.com/help#topic123
现在,要求已更改,并且已被告知要使用查询字符串sitename.com?showhelp将(临时)/ help重定向到主页。
我在web.config中使用了重定向规则,该规则在主要帮助页面上工作正常。
Requested URL: sitename.com/help
Redirected to URL: sitename.com?showhelp
问题当我将特定主题URL重定向到新主题URL时,它仍在URL末尾显示#topic123,例如
Requested URL: sitename.com/help#topic123
Redirected to URL: sitename.com?showhelp#topic123
Required URL: sitename.com?showhelp
使用的规则:
<rule name="newhelp" stopProcessing="true">
<match url="^help" />
<action type="Redirect" url="?showhelp" redirectType="Temporary" />
</rule>
我也尝试过从控制器操作方法重定向,但这不能解决问题。 我无法从Request.Url中读取#topic123部分
使用(#。+)获得额外的片段
<rule name="newhelp" stopProcessing="true">
<match url="^help(#.+)?" />
<action type="Redirect" url="?showhelp{R:1}" redirectType="Temporary" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.