在的Index.aspx混合ASP.NET / ASP.NET MVC应用程序 [英] Index.aspx in a hybrid ASP.NET / ASP.NET MVC application
问题描述
我有一个混合asp.net和asp.net MVC3应用。这原本只是ASP.NET。默认页面仍然在ASP.NET当用户进入 http://mysite.com/ 我想要的Index.aspx的就上来了。当然, routes.MapRoute(默认,{控制器} / {行动} / {ID},新{控制器=家,行动=索引,ID =在我的Global.asax})
行IR THT重新路由到我的MVC网页。
I have a hybrid asp.net and asp.net mvc3 application. It was originally just ASP.NET. The default page is still in ASP.NET and when a user goes to http://mysite.com/ I want the index.aspx to come up. Of course, the routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" })
line in my global.asax ir rerouting tht to my MVC pages.
我尝试以下,但他们都没有工作:
I tried the following but neither of them worked:
routes.MapRoute("DefaultPage", "/", "~/Index.aspx");
routes.IgnoreRoute("{resource}.aspx/{*pathinfo}");
有谁知道我应该做的?
Does anybody know what I should be doing?
推荐答案
要映射根的Index.aspx你需要使用的MapPageRoute,而不是图路线,方法如下:
To map the root to Index.aspx you need to use MapPageRoute, rather than MapRoute, as follows:
routes.MapPageRoute("DefaultPage", "", "~/Index.aspx");
routes.IgnoreRoute("{resource}.aspx/{*pathinfo}");
此外,还要确保这些行之前的默认路由映射放置。
Also ensure these lines are placed prior to the default route mapping.
这篇关于在的Index.aspx混合ASP.NET / ASP.NET MVC应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!