我找不到解决这个问题的办法。
我必须在一个项目中加入两个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);
}
}
} 问题:
非常感谢!
发布于 2012-01-09 09:02:48
尝试使用来自Asp.net MVC-3的“区域”。
这样,您就可以最好地控制URL和输出。
发布于 2012-01-09 09:38:05
在MVC3中,区域是非常好的特性,您可以这样简单地进行路由。
"MVCApplication1/{controller}/{action}/{id}"
"MVCApplication2/{controller}/{action}/{id}"发布于 2016-05-18 23:16:10
在Global.asax中,检查是否已经注册了这些区域。
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();https://stackoverflow.com/questions/8785898
复制相似问题