【问题标题】:routing issue when redirecting from aspx to cshtml page从 aspx 重定向到 cshtml 页面时的路由问题
【发布时间】:2013-12-27 10:15:48
【问题描述】:

我正在尝试使用路由将我的旧网站页面 aspx 重定向到我在 mvc 4(cshtml) 中的新网站页面,我在 Global.asax 中添加了此代码

routes.MapRoute(
    name: "Contact",
    url: "Contact.aspx",
    defaults: new { 
        controller = "Home", 
        action = "Contact", 
        id = UrlParameter.Optional 
    }
);

它工作正常,但每次发布后它都会显示 Contact.aspx 而不是 /Home/Contact 我该怎么办?

当我填写联系我们的表格时,它的发布操作会在地址栏中显示 Contact.aspx

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing


    【解决方案1】:

    您应该永久重定向而不是尝试进行路由。这是一个nice blog post,它说明了如何编写将执行重定向的自定义路由。

    【讨论】:

      猜你喜欢
      • 2014-09-15
      • 2013-07-13
      • 1970-01-01
      • 2012-10-15
      • 2014-08-03
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多