First shot at throwing a question on these boards so hopefully I can get some help, here goes:
第一次在这些板上抛出一个问题,希望我能得到一些帮助,这里有:
I am working to start up the .NET practice at my client. We have 5 small scale .NET applications in place currently with a few them of them live into production. They're mostly small reporting pieces with some data entry/business logic functionality. Each of these applications is currently using the identical master pages.
我正在努力在我的客户端启动.NET实践。我们现在有5个小规模的.NET应用程序,其中一些已经投入生产。它们主要是具有一些数据输入/业务逻辑功能的小型报表。这些应用程序中的每一个当前都使用相同的母版页。
What I mean is that there is a copy of the same master page in each application. They are all basic website->WCF->BL->DB tiered applications. So I have 4 copies of the same master page that I have to change when I make a change to it.
我的意思是每个应用程序中都有相同母版页的副本。它们都是基本的网站 - > WCF-> BL-> DB分层应用程序。因此,当我对其进行更改时,我必须更改同一母版页的4个副本。
The client DOES NOT want to consolidate all of these into a single solution. They like the separation of applications across sites. I just don't want to continue dealing with the hassle of multiple updates for common elements (which there will be many more of across these applications).
客户不希望将所有这些整合到一个解决方案中。他们喜欢跨站点分离应用程序。我只是不想继续处理常见元素的多个更新的麻烦(这些应用程序中会有更多更新)。
The code is all stored in team foundation server. We also do NOT want to compile the master page into a .dll and deploy it.
代码全部存储在团队基础服务器中。我们也不想将母版页编译成.dll并进行部署。
Can anyone please make some suggestions as to how I can maintain a single copy of these common files (master, .css, etc) across my multiple applications.
任何人都可以就如何在我的多个应用程序中维护这些常见文件(master,.css等)的单个副本提出一些建议。
thanks in advance
提前致谢
6 个解决方案
#1
You might want to look at Sharing Master Pages in Visual Studio.
您可能希望查看Visual Studio中的“共享母版页”。
If that is no help then you could try using Build Events in Visual Studio. I would pick one of the projects to be my "Main Project" and only edit the master page from that project. When you build the project it would run a command that would copy that master page(if it had changed) to your set locations.
如果没有帮助,那么您可以尝试在Visual Studio中使用Build Events。我会选择其中一个项目作为我的“主项目”,只编辑该项目的母版页。在构建项目时,它将运行一个命令,将该母版页(如果已更改)复制到您的设置位置。
#2
The client DOES NOT want to consolidate all of these into a single solution. They like the separation of applications across sites. I just dont want to continue dealing with the hassle of multiple updates for common elements (which there will be many more of across these applications).
客户不希望将所有这些整合到一个解决方案中。他们喜欢跨站点分离应用程序。我只是不想继续处理常见元素的多个更新的麻烦(这些应用程序中会有更多更新)。
The code is all stored in team foundation server. We also do NOT want to compile the master page into a dll and deploy it.
代码全部存储在团队基础服务器中。我们也不想将母版页编译成dll并进行部署。
You eliminated the only two real options there. What all is in the master page? Would it be possible to extract the HTML UI elements to a single template or series of template HTML files and import those dynamically into the master page? You could then relocate the common HTML to an arbitrary URL and have the master page for each application pull it in dynamically.
你消除了那里唯一的两个真实选择。主页中的内容是什么?是否可以将HTML UI元素提取到单个模板或一系列模板HTML文件中,并将它们动态导入到母版页中?然后,您可以将公共HTML重定位到任意URL,并让每个应用程序的母版页动态地将其拉入。
Edit: I lied. You could also use a VirtualPathProvider like Sharepoint does to store the master page in a database or some other directory, but beware that VirtualPathProviders do not work in MediumTrust environments.
编辑:我骗了。您也可以使用像Sharepoint这样的VirtualPathProvider将母版页存储在数据库或其他目录中,但要注意VirtualPathProviders在MediumTrust环境中不起作用。
See:
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
#3
If you are using Web Applications (compiled into a dll) rather than Web Sites you can do the following:
如果您使用Web应用程序(编译为dll)而不是网站,则可以执行以下操作:
Right click on the folder you want to store the master page in
右键单击要存储母版页的文件夹
Select "Add Existing Item..."
选择“添加现有项目...”
Browse to the master page on the file system, and select both the .master and the .master.cs files.
浏览到文件系统上的母版页,然后选择.master和.master.cs文件。
Then, rather than clicking on the "Add" button, click on the little down arrow to the right of Add, this will bring up a little menu with the options: "Add" and "Add As Link"
然后,不要单击“添加”按钮,而是单击“添加”右侧的小向下箭头,这将显示一个带有选项的小菜单:“添加”和“添加为链接”
Select "Add As Link" this will reference the file in your project, while leaving it in the original location in your dev environment - this allows you to edit it in either application, while keeping it up to date in the other applications.
选择“添加为链接”,这将引用项目中的文件,同时将其保留在开发环境中的原始位置 - 这允许您在任一应用程序中编辑它,同时在其他应用程序中保持最新。
Obviously if you edit the code behind, you'll need to re-compile the other projects before you deploy the changes to those sites.
显然,如果您编辑后面的代码,则需要在将更改部署到这些站点之前重新编译其他项目。
This isn't available in web site projects as they rely on the file structure to work out what is in the project.
这在网站项目中不可用,因为它们依赖于文件结构来计算项目中的内容。
#4
EDIT: Missed the css part. Obviously you won't be able to serve those files, so this should only work for the master page.
编辑:错过了css部分。显然,您将无法提供这些文件,因此这仅适用于母版页。
Don't know your scenario, so
不知道你的情况,所以
IF you can control the DNS / virtual directories to the applications you could use a format like this:
如果您可以控制DNS /虚拟目录到应用程序,您可以使用这样的格式:
c:\inetpub\wwwroot\Application1
c:\inetpub\wwwroot\Application2
c:\inetpub\wwwroot\Application3
c:\inetpub\wwwroot\Application4
c:\inetpub\wwwroot\Application5
and have your Master page at c:\inetpub\wwwroot\master.Master,
c:\inetpub\wwwroot\master.Master.cs,
c:\inetpub\wwwroot\master.Master.cs.designer
c:\ inetpub \ wwwroot \ Application1 c:\ inetpub \ wwwroot \ Application2 c:\ inetpub \ wwwroot \ Application3 c:\ inetpub \ wwwroot \ Application4 c:\ inetpub \ wwwroot \ Application5并将您的母版页放在c:\ inetpub \ wwwroot \ master.Master,c:\ inetpub \ wwwroot \ master.Master.cs,c:\ inetpub \ wwwroot \ master.Master.cs.designer
Then you could reference the single copy of the master page from /../master.Master. I gave this a quick shot with a precompiled master page to make sure I could reach back beyond my root. You might have to give it a shot to see.
然后,您可以从/../master.Master引用母版页的单个副本。我用预编译的母版页快速拍摄了这张图片,以确保我可以回到我的根本之外。你可能不得不试一试。
#5
We use our source control to create links to the shared files in all the places that we need it. So if you edit in one place, you just need to do a get latest and it will appear in the other places you have linked it.
我们使用源代码控制在我们需要的所有位置创建指向共享文件的链接。因此,如果您在一个地方进行编辑,您只需要获取最新信息,它就会显示在您已将其链接到的其他位置。
#6
I ended up going with the VPP route. I created a virtual path provider and built my master page into a DLL and this is working. Now I have a massive problem though in that a Content page whos master page is late bound through the codebehind throws validation/formatting hissy fits because it thinks its should be a stand along page. my CNTRL + K, CNTRL + D has broken on every page where I'm now sharing my master page. This is extremely frustring for me and the team
我最终选择了VPP路线。我创建了一个虚拟路径提供程序并将我的母版页构建到DLL中,这是有效的。现在我遇到了一个很大的问题,因为一个内容页面,即主页面通过代码隐藏抛出后期绑定验证/格式化hissy适合,因为它认为它应该是一个支持页面。我的CNTRL + K,CNTRL + D在我现在正在共享我的母版页的每个页面上都打破了。这对我和团队来说非常有吸引力
#1
You might want to look at Sharing Master Pages in Visual Studio.
您可能希望查看Visual Studio中的“共享母版页”。
If that is no help then you could try using Build Events in Visual Studio. I would pick one of the projects to be my "Main Project" and only edit the master page from that project. When you build the project it would run a command that would copy that master page(if it had changed) to your set locations.
如果没有帮助,那么您可以尝试在Visual Studio中使用Build Events。我会选择其中一个项目作为我的“主项目”,只编辑该项目的母版页。在构建项目时,它将运行一个命令,将该母版页(如果已更改)复制到您的设置位置。
#2
The client DOES NOT want to consolidate all of these into a single solution. They like the separation of applications across sites. I just dont want to continue dealing with the hassle of multiple updates for common elements (which there will be many more of across these applications).
客户不希望将所有这些整合到一个解决方案中。他们喜欢跨站点分离应用程序。我只是不想继续处理常见元素的多个更新的麻烦(这些应用程序中会有更多更新)。
The code is all stored in team foundation server. We also do NOT want to compile the master page into a dll and deploy it.
代码全部存储在团队基础服务器中。我们也不想将母版页编译成dll并进行部署。
You eliminated the only two real options there. What all is in the master page? Would it be possible to extract the HTML UI elements to a single template or series of template HTML files and import those dynamically into the master page? You could then relocate the common HTML to an arbitrary URL and have the master page for each application pull it in dynamically.
你消除了那里唯一的两个真实选择。主页中的内容是什么?是否可以将HTML UI元素提取到单个模板或一系列模板HTML文件中,并将它们动态导入到母版页中?然后,您可以将公共HTML重定位到任意URL,并让每个应用程序的母版页动态地将其拉入。
Edit: I lied. You could also use a VirtualPathProvider like Sharepoint does to store the master page in a database or some other directory, but beware that VirtualPathProviders do not work in MediumTrust environments.
编辑:我骗了。您也可以使用像Sharepoint这样的VirtualPathProvider将母版页存储在数据库或其他目录中,但要注意VirtualPathProviders在MediumTrust环境中不起作用。
See:
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
#3
If you are using Web Applications (compiled into a dll) rather than Web Sites you can do the following:
如果您使用Web应用程序(编译为dll)而不是网站,则可以执行以下操作:
Right click on the folder you want to store the master page in
右键单击要存储母版页的文件夹
Select "Add Existing Item..."
选择“添加现有项目...”
Browse to the master page on the file system, and select both the .master and the .master.cs files.
浏览到文件系统上的母版页,然后选择.master和.master.cs文件。
Then, rather than clicking on the "Add" button, click on the little down arrow to the right of Add, this will bring up a little menu with the options: "Add" and "Add As Link"
然后,不要单击“添加”按钮,而是单击“添加”右侧的小向下箭头,这将显示一个带有选项的小菜单:“添加”和“添加为链接”
Select "Add As Link" this will reference the file in your project, while leaving it in the original location in your dev environment - this allows you to edit it in either application, while keeping it up to date in the other applications.
选择“添加为链接”,这将引用项目中的文件,同时将其保留在开发环境中的原始位置 - 这允许您在任一应用程序中编辑它,同时在其他应用程序中保持最新。
Obviously if you edit the code behind, you'll need to re-compile the other projects before you deploy the changes to those sites.
显然,如果您编辑后面的代码,则需要在将更改部署到这些站点之前重新编译其他项目。
This isn't available in web site projects as they rely on the file structure to work out what is in the project.
这在网站项目中不可用,因为它们依赖于文件结构来计算项目中的内容。
#4
EDIT: Missed the css part. Obviously you won't be able to serve those files, so this should only work for the master page.
编辑:错过了css部分。显然,您将无法提供这些文件,因此这仅适用于母版页。
Don't know your scenario, so
不知道你的情况,所以
IF you can control the DNS / virtual directories to the applications you could use a format like this:
如果您可以控制DNS /虚拟目录到应用程序,您可以使用这样的格式:
c:\inetpub\wwwroot\Application1
c:\inetpub\wwwroot\Application2
c:\inetpub\wwwroot\Application3
c:\inetpub\wwwroot\Application4
c:\inetpub\wwwroot\Application5
and have your Master page at c:\inetpub\wwwroot\master.Master,
c:\inetpub\wwwroot\master.Master.cs,
c:\inetpub\wwwroot\master.Master.cs.designer
c:\ inetpub \ wwwroot \ Application1 c:\ inetpub \ wwwroot \ Application2 c:\ inetpub \ wwwroot \ Application3 c:\ inetpub \ wwwroot \ Application4 c:\ inetpub \ wwwroot \ Application5并将您的母版页放在c:\ inetpub \ wwwroot \ master.Master,c:\ inetpub \ wwwroot \ master.Master.cs,c:\ inetpub \ wwwroot \ master.Master.cs.designer
Then you could reference the single copy of the master page from /../master.Master. I gave this a quick shot with a precompiled master page to make sure I could reach back beyond my root. You might have to give it a shot to see.
然后,您可以从/../master.Master引用母版页的单个副本。我用预编译的母版页快速拍摄了这张图片,以确保我可以回到我的根本之外。你可能不得不试一试。
#5
We use our source control to create links to the shared files in all the places that we need it. So if you edit in one place, you just need to do a get latest and it will appear in the other places you have linked it.
我们使用源代码控制在我们需要的所有位置创建指向共享文件的链接。因此,如果您在一个地方进行编辑,您只需要获取最新信息,它就会显示在您已将其链接到的其他位置。
#6
I ended up going with the VPP route. I created a virtual path provider and built my master page into a DLL and this is working. Now I have a massive problem though in that a Content page whos master page is late bound through the codebehind throws validation/formatting hissy fits because it thinks its should be a stand along page. my CNTRL + K, CNTRL + D has broken on every page where I'm now sharing my master page. This is extremely frustring for me and the team
我最终选择了VPP路线。我创建了一个虚拟路径提供程序并将我的母版页构建到DLL中,这是有效的。现在我遇到了一个很大的问题,因为一个内容页面,即主页面通过代码隐藏抛出后期绑定验证/格式化hissy适合,因为它认为它应该是一个支持页面。我的CNTRL + K,CNTRL + D在我现在正在共享我的母版页的每个页面上都打破了。这对我和团队来说非常有吸引力