Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用MVC路由重定向.aspx网页_Asp.net_Asp.net Mvc_Webforms_Asp.net Mvc Routing - Fatal编程技术网

Asp.net 使用MVC路由重定向.aspx网页

Asp.net 使用MVC路由重定向.aspx网页,asp.net,asp.net-mvc,webforms,asp.net-mvc-routing,Asp.net,Asp.net Mvc,Webforms,Asp.net Mvc Routing,我有ASP.NE Web表单应用程序,其中我有ASP.NET MVC区域(带razor视图引擎) 我在这个位置有一个aspx页面project/pages/email.aspx 不管是爬网代理还是一些用户,他们都可以请求http://wwww.mydomain.com/pages/email.aspx?param1=2¶m2=3 我想将此请求重定向到“PageNotFound” 以下不是选项: 删除该页面:因为该aspx页面在我的应用程序中用于其他目的 不想在PageLod事件上执行重定

我有ASP.NE Web表单应用程序,其中我有ASP.NET MVC区域(带razor视图引擎)

我在这个位置有一个aspx页面
project/pages/email.aspx
不管是爬网代理还是一些用户,他们都可以请求
http://wwww.mydomain.com/pages/email.aspx?param1=2¶m2=3

我想将此请求重定向到“PageNotFound

以下不是选项:

  • 删除该页面:因为该aspx页面在我的应用程序中用于其他目的
  • 不想在PageLod事件上执行重定向(如果这是最好的方法,请更正我。)
  • 有兴趣知道这种方式是否可行:

  • 通过ASP.NET MVC区域(它是我的Web窗体应用程序的一部分)处理路由配置
  • 伊萨皮
  • Web.config/Global.asax
  • 注:
    这必须是301永久重定向。

    您可以在web.config中执行以下操作:

    就你的情况来看

    <configuration>
      <location path="email.aspx">
        <system.webServer>
          <httpRedirect enabled="true" destination="http://domain.com/PageNotFound.aspx" httpResponseStatus="Permanent" />
        </system.webServer>
      </location>
    </configuration>
    
    
    

    或者,您可以查看IIS中的。

    无论是谁否决了这个问题,我都很感谢您对否决问题的评论。这是一个好问题+1在我的情况下,我只想在请求来自MVC区域时重定向,但如果请求来自主应用程序,则不想重定向。那么,我应该在我的ASP.NET MVC区域文件夹中创建一个WEb.config并在那里添加这个httpRedirect吗?