2

I cannot find a solution with this problem.
I have to join TWO MVC3 projects in ONE project. And to do that I have to put them on separate folders. To see what I mean, let's see these images:

First Project:

enter image description here

After putting in a folder:

enter image description here

Now when I run the project I got this error:

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  

Inside 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);
        }
    }
}  

Question:

  1. What should be the configuration of my global.asax? (For I suspect that the problem starts here)
  2. If number one is possible to be solved, then how would I map the route of second MVC3 project?

Thanks a lot!!!!

tereško
  • 58,060
  • 25
  • 98
  • 150
fiberOptics
  • 6,955
  • 25
  • 70
  • 105

3 Answers3

4

Try Using "Areas" from Asp.net MVC-3

that way you can best control the URL and the output both.

Anuj Pandey
  • 938
  • 2
  • 11
  • 30
1

Areas are very nice feature in MVC3, you simply will be able to route it like this.

"MVCApplication1/{controller}/{action}/{id}"

"MVCApplication2/{controller}/{action}/{id}"

see here

Community
  • 1
  • 1
hackp0int
  • 4,052
  • 8
  • 59
  • 95
0

In Global.asax check if you already register the areas.

protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
L3X
  • 1
  • 1