Hi @Malam Malam,
When I add Project2 in Project1, I get a long list of errors.
How do you add Project2 to Project1?
What's the best way to combine these two projects in to one solution?
Maybe you can try using Area. Area allows us to divide a large application into smaller units, each unit contains a separate MVC folder structure, the same as the default MVC folder structure.
Here is a simple example.
Creating an Area
right click on project Add -> New Scaffolded Item -> MVC Area.
each area includes the AreaRegistration
class. The following is adminAreaRegistration
class created with admin area.
public class adminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"admin_default",
"admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
The AreaRegistration
class overrides the RegisterArea
method to map the routes for the area. In the above example, any URL that starts with the admin will be handled by the controllers included in the admin folder structure under the Area
folder. For example, http://localhost/admin/profile
will be handled by the profile controller included in the Areas/admin/controller/ProfileController
folder.
Finally, all the areas must be registered in the Application_Start
event in Global.asax.cs
as AreaRegistration.RegisterAllAreas();
.
So in this way, you can create and maintain multiple areas for the large application.
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.