我有ASP.NE Web Forms应用程序,其中我有ASP.NET MVC区域(使用razor视图引擎)
我在这个位置有一个aspx页面project/pages/email.aspx
不管怎样,无论是来自抓取代理还是某些用户,他们都可以请求http://wwww.mydomain.com/pages/email.aspx?param1=2¶m2=3
我想将此类请求重定向到“ PageNotFound ”
以下不是选项:
有兴趣知道这种方式是否可行:
注意: 这必须是301永久重定向。
答案 0 :(得分:0)
您可以通过以下方式在web.config中执行此操作:https://stackoverflow.com/a/10400010/412451
在你的情况下,它看起来像
<configuration>
<location path="email.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="http://domain.com/PageNotFound.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
或者,您可以查看IIS中的URL Rewrite module。