【问题标题】:Map URL to empty route in ASP.NET MVC 2 from URL. URL displays blank page将 URL 从 URL 映射到 ASP.NET MVC 2 中的空路由。 URL 显示空白页
【发布时间】:2011-01-05 08:00:30
【问题描述】:

如果网址是
http://localhost:54027/test1/test2/home
它显示主页

如果网址是
http://localhost:54027/test1/test2/
它显示空白页


以下是我们使用的路线

routes.MapRoute(
              "HomePage",
              "Test2",
              new { controller = "Home", action = "Index", id = "", title = UrlParameter.Optional }
          );
            routes.MapRoute(
            "ProductDetails", // Route name
            "Test2/", // URL with parameters
            new { controller = "Home", action = "Index", id = "", title = UrlParameter.Optional } // Parameter defaults
            );
            routes.MapRoute(
                "Default",
                "Test2/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = "1" }
            );



如果我们尝试跟随 URL,它可以正常工作
http://localhost:54027/test1/test2/'

routes.MapRoute(
            "ProductDetails", // Route name
            "Test2/{'}", // URL with *** ' *** parameters
            new { controller = "Home", action = "Index", id = "", title = UrlParameter.Optional } // Parameter defaults
            );

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-2 routes url-routing maproute


    【解决方案1】:

    我们创建了一个虚拟页面作为空白页面,并将 Response.Redirect 添加到主页 这不是问题的解决方案,但我们解决了它。

    【讨论】:

      猜你喜欢
      • 2011-11-11
      • 2015-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多