简体   繁体   中英

Parent and Child Websites hosted locally - MVC

I have a MVC web application. Lets call it "Parent" website. In order to set up the website on my local machine, I go to IIS, create a new website and in the "edit website" screen, in "physical path" I give the location of the folder on my hard drive. That website works fine with few modifications with application pool, port number etc..

What I am trying to do after that is - to set up another "Child" website using the same code base. This child website runs off a single controller, few specific models, few specific views, but common service layer to parent website above. When I set up this new child website on my local machine, I would like it to act as a stand alone website, just picking up parts of the main code base that are relevant to its functionality ONLY. How do I do this in a efficient way so I have both Parent and Child websites running separately on IIS on my local machine with one common code base.

This is what I tried but got only so far.. not sure if this even the right direction.

I tried creating a new MVC "Area" for this child site, for example, I moved the ChildController, ChildModels and ChildViews into this new ChildArea. I was hoping this would somehow make it easy to separate parent and child websites and host them locally. In the main folder structure, (Parent), I have site.master page that works well for Parent website already hosted and working well. I also have a new site.master inside the new MVC area that I need the child website to take for display.

I need some help and guidance on how I can achieve this. Thanks in advance for comments, solutions, feedback.

在此处输入图片说明

Create a solution with 3 projects.

  1. Parent Website
  2. Child Website
  3. A DLL project that contains shared code.

Move the common components from your parent site into the Shared project.

The Parent site and the Child would both reference the 3rd common code library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM