简体   繁体   English

本地托管的父子网站-MVC

[英]Parent and Child Websites hosted locally - MVC

I have a MVC web application. 我有一个MVC Web应用程序。 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. 为了在本地计算机上设置网站,我转到IIS,创建一个新网站,然后在“编辑网站”屏幕的“物理路径”中,指定文件夹在硬盘驱动器上的位置。 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. 我如何以一种有效的方式做到这一点,所以我的父母网站和子网站都在本地计算机上的IIS上运行,并且使用一个通用代码库。

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. 我尝试为此子站点创建一个新的MVC“区域”,例如,我将ChildController,ChildModels和ChildViews移到了这个新的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. 在主文件夹结构(Parent)中,我有site.master页面,该页面对于已托管且运行良好的Parent网站非常有效。 I also have a new site.master inside the new MVC area that I need the child website to take for display. 在新的MVC区域中,我还有一个新的site.master,需要子网站进行展示。

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. 创建一个包含3个项目的解决方案。

  1. Parent Website 家长网站
  2. Child Website 子网站
  3. A DLL project that contains shared code. 包含共享代码的DLL项目。

Move the common components from your parent site into the Shared project. 将公共组件从您的父站点移到Shared项目中。

The Parent site and the Child would both reference the 3rd common code library. 父站点和子站点都将引用第三通用代码库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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