Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run ASP.NET MVC project inside another ASP.NET MVC project

Let's say I have a MVC project where there is root folder MVC2 and. Now, I want another MVC project to that MVC2 folder and serve it.

Below url should serve MVC2 project which is just a folder inside the root project. Root project is also MVC.

  • currentSite.com -> current mvc app
  • currentSite.com/MVC2/ -> should run nested mvc app.

I think there should be a webconfig setting which should make it work.

Thank you in advance. Any answer will be dearly appreciated.

Is it possible? and if it is , is it possible to interact with each other.

like image 594
Random Identity Avatar asked Nov 19 '25 06:11

Random Identity


1 Answers

I would strongly re-consider your architecture if you're having to embed MVC projects within one another. Depending on how closely related the two are, I would think about going in the following directions:

  1. MVC Areas - If both your projects are heavily linked, share a lot of the same code and resources then I would put them as two separate areas within your application. Default area routing would give you currentSite.com/MVC2 aswell, provided your area was called MVC2. This approach means you'd always deploy both sites together as well (if that's something you need to consider).
  2. Separate Projects - If there's not a great deal of similarity between the two and you'd prefer to keep them separate, then simply have them both sit in one solution and migrate the common code into a separate class library project that sits within the same solution. You can even compile your views using something like RazorGenerator if you need to share any views between the two projects. This approach also means that you can deploy your sites separately as well should you need to. To achieve the desired URL of currentSite.com/MVC2 in this scenario then you can simply set it up as a virtual directory in IIS.
like image 145
mattytommo Avatar answered Nov 21 '25 20:11

mattytommo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!