我找不到解决这个问题的方法 我必须在一个项目中加入两个MVC3项目。要做到这一点,我必须将它们放在单独的文件夹中。看看我的意思,让我们看看这些图片:
第一个项目:
放入文件夹后:
现在,当我运行项目时出现了这个错误:
Server Error in '/' Application.
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
内部Global.asax
:
namespace MvcApplication1
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
}
问题:
非常感谢!!!!
答案 0 :(得分:4)
尝试使用Asp.net MVC-3中的“区域”
通过这种方式,您可以最好地控制URL和输出。
答案 1 :(得分:1)
MVC3中的区域是一个非常好的功能,你只需要像这样路由它。
"MVCApplication1/{controller}/{action}/{id}"
"MVCApplication2/{controller}/{action}/{id}"
答案 2 :(得分:0)
在Global.asax中检查您是否已注册区域。
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();