你可以只在您的Web應用程序的子文件夾中創建你的MVC應用程序,然後移動任何Global.asax中配置你的Web窗體應用程序
你只需要更新你的路由,如果你的MVC應用程序的創建一個名爲MVC的文件夾中,可能是這個樣子:
routes.MapRoute(
"MVC default",
"MVC/default.aspx",
new { controller = "Home", action = "Index", id = "" }
);
routes.MapRoute(
"Services",
"MVC/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
編輯:
其實你需要映射確保您的意見是正確映射也一樣,你可以通過創建一個快速自定義視圖引擎做到這一點:
public class CustomViewEngine : System.Web.Mvc.WebFormViewEngine
{
public CustomViewEngine()
{
base.ViewLocationFormats = new string[]
{
"~/MVC/Views/{1}/{0}.aspx",
"~/MVC/Views/{1}/{0}.ascx",
"~/MVC/Views/Shared/{0}.aspx",
"~/MVC/Views/Shared/{0}.ascx"
};
base.PartialViewLocationFormats = new string[] {
"~/MVC/Views/{1}/{0}.aspx",
"~/MVC/Views/{1}/{0}.ascx",
"~/MVC/Views/Shared/{0}.aspx",
"~/MVC/Views/Shared/{0}.ascx"
};
base.MasterLocationFormats = new string[]
{
"~/MVC/Views/{1}/{0}.master",
"~/MVC/Views/Shared/{0}.master"
};
}
}
,然後登記在您的Global.asax:
System.Web.Mvc.ViewEngines.Engines.Clear();
System.Web.Mvc.ViewEngines.Engines.Add(new CustomViewEngine());
來源
2011-04-19 13:13:01
Dve