将 URL 从 URL 映射到 ASP.NET MVC 2 中的空路由。 URL显示空白页
如果网址是
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
);
If URL is
http://localhost:54027/test1/test2/home
It shows home page
If URL is
http://localhost:54027/test1/test2/
It shows BLANK page
Following are the routes we have used
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" }
);
If we try following URL it works fine
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
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们创建了一个虚拟页面作为空白页面,并将 Response.Redirect 添加到主页
这不是问题的解决方案,但我们解决了它。
We have created a dummy page as blank page and added Response.Redirect to home page
This is not the solution to the problem, but we worked around it.