How to integrate a template published as web applications with web applications using this shell?

I have the following case:

My current projects are as follows:

A master page and set of pages.aspx inherit the layout from the main page.

Now I want to do it on a large scale. So what I want to do:

Two types of projects published as two separate web applications (Loosely Coupled):

  • a wrapper (a basic common template for all other application websites) to replace (the main page used in the same
    application), this project is used as a structure or template similar to this: (Header,Footer) , [(Sidebar(Menu),Body) dynamic according to the web application which use the wrapper] .

enter image description here

  1. Any web application will fill the wrapper with two parts (body and Menu) dynamically.

How to integrate the shell and web applications that should use this shell, and both of them are published as two separate web applications?


Note:

Most importantly, I do not want every change in the package ( wrapper ) to republish all applications that use this package ( wrapper ) for updating.

+6
source share
2 answers

I solved this problem in the past using NuGet packages. They can be as complex or as simple as you need. The main layout of the main page can be achieved simply by manually creating . A nuspec file by building it using a command line tool and placing it on a file system (local or network).

Add the configuration file to the root of your template project - name it template.nuspec and add the following:

 <?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <id>MyAppTemplate</id> <version>1.0.0</version> <description>A template web application</description> <authors>Me or my company</authors> </metadata> <files> <file src="Site.Master" target="content\Site.Master" /> <file src="Site.Master.cs" target="content\Site.Master.cs" /> <file src="Site.Master.designer.cs" target="content\Site.Master.designer.cs" /> </files> </package> 

Please note that the goal is β€œcontent” - this will remove the main page at the root of the project wherever the NuGet package is installed. You can also change the namespace of the main page to $rootnamespace$ , as this will make the source code conversion , which will make the main page part of the same namespace as the rest of your project.

At the command line, you can simply call nuget.exe pack path\to\nuspec\file

which will lead to the creation of a .nupkg file. For local development, I usually drop it into C:\NuGet\Local , although it may be a network resource \\MyShare\InternalNuget , or there are solutions like ProGet or TeamCity if you want to take it further.

Then in Visual Studio you can add it as a package source:

Tools β†’ NuGet Package Manager β†’ Package Manager Settings β†’ Package Sources

Click the plus sign and add the folder / path / url, and then you can reuse it in any other project.

As a general rule, it is better to allow NuGet to overwrite the existing Site.Master when creating the project, and then not edit the files, as this allows you to centrally manage changes using version control of NuGet packages. However, if you want to make specific changes to the project, you can do it, you just need to remember that the NuGet package overwrites the version of the project with subsequent updates.

You can include all file types from your project template. This includes .ascx user controls, css and javascript files, as well as compiled or unrelated base pages (inheriting from System.Web.UI.Page ). The possibilities are endless. Using <asp:contentplaceholder/> and the appropriate CSS, you can use the general menu in most projects through a user control, but still replace it with a more complex menu in other projects without changing the main template.

EDIT:

I assume that you can achieve the desired effect (at least for relatively simple content) by dividing the wrapper into two parts. The first will be the NuGet package containing the main page. This main page may contain iframes for the header and footer in the diagram, content placeholders and css and script tags for common styles and javascript.

The second part of the shell will be a separate application containing the contents of frames and .css and .js files. Major changes, such as adding a new javascript library, still require updating the main page, but small changes, such as adding a new function or css class or changing a brand or logo, can be made by changing the wrapper files and republishing them. It seems like placing your own simple CDN.

The main page is as follows:

 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="$rootnamespace$.SiteMaster" %> <html> <head runat="server"> <title><%: Page.Title %></title> <link href="https://example.com/mywrapperapplication/styles/mywrapper.css" rel="stylesheet" /> </head> <body> <iframe src="https://example.com/mywrapperapplication/header.html" /> <form runat="server"> <asp:ContentPlaceHolder ID="MenuContent" runat="server"></asp:ContentPlaceHolder> <asp:ContentPlaceHolder ID="BodyContent" runat="server"></asp:ContentPlaceHolder> </form> <iframe src="https://example.com/mywrapperapplication/footer.html" /> <script type="text/javascript" src="https://example.com/mywrapperapplication/scripts/mywrapper.js"></script> </body> </html> 

Then you have static content or a simple application deployed to https://example.com/mywrapperapplication

with 4 (or more) files:

 header.html --or aspx or whatever footer.html /scripts/mywrapper.js /styles/mywrapper.css 

Any changes you make to any of these files will be automatically distributed in the wrapped application, since they are associated with the main page. You will need to re-publish the wrapped application if you want to add an additional file, for example

 <link href="https://example.com/mywrapperapplication/styles/mynewstyles.css" rel="stylesheet" /> 
+3
source

Why not publish consumed applications as user controls and use the main page (your wrapper) programmatically, as DotNetNuke does.

https://msdn.microsoft.com/en-us/library/c0az2h86.aspx

User controls can be compiled separately and will not be recompiled when replacing the shell.

+2
source

Source: https://habr.com/ru/post/1012558/


All Articles