【问题标题】:route aspx to controller将 aspx 路由到控制器
【发布时间】:2015-03-18 14:24:42
【问题描述】:

我尝试使用路由系统将 aspx 中的旧页面版本重定向到我的控制器中。

示例:

old Urlpage : ~/mypage.aspx?extraparam=123
new UrlPage : ~/HomeMyaction?extraparam=123 (or /Home/MyAction/123)

我试试这个:

routes.MapRoute(
                name: "MyPage",
                url: "mypage.aspx",
                defaults: new { controller = "Home", action = "MyAction" },
                namespaces: new string[] { "MyApp.Controllers" });


routes.MapRoute(
                name: "MyPage",
                url: "{namepage}.aspx",
                defaults: new { controller = "Home", action = "MyAction" },
                namespaces: new string[] { "MyApp.Controllers" });

但每次尝试我的网站都会返回错误 404,因为他尝试访问“mypage.aspx”,但它们不再存在,我无法更改旧的访问权限。

我尝试像 .axd 一样忽略“mypage.aspx”

routes.IgnoreRoute("mypage.aspx/{*pathInfo}");

但我总是 404 BadRequest 'Ressources not found'

【问题讨论】:

    标签: c# model-view-controller routes


    【解决方案1】:

    关闭 VisualStudio 并重新构建我的整个解决方案后,我的路线工作正常。

    不知道为什么……

    我用这个:

    routes.MapRoute(
                name: "MyPage",
                url: "mypage.aspx",
                defaults: new { controller = "Home", action = "MyAction" },
                namespaces: new string[] { "MyApp.Controllers" });
    

    【讨论】:

      猜你喜欢
      • 2013-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 2015-02-14
      • 1970-01-01
      • 2015-05-10
      相关资源
      最近更新 更多