Composite Web Client Guide

Good afternoon,

I was wondering if you can help me,

I read a guide related to the following: Composite web guides

I read the section "Determining the solution structure for a modular web application", in particular the section "Multiproject modules". I seem to understand the basic concepts associated with this, however I cannot find a reasonable way to allow this to work with my web forms in separate projects .

I understand that development time support for master pages is not supported here, but my question is how to use something like unity (or another container) to let me deploy my projects (including web form pages and code for files), since they are completely folder-independent and connect them to the solution, the manual seems a bit unclear as to how to support this, and whenever I try to import these modules, I get errors at runtime. I have successfully worked with MVC exporting controllers. I would be grateful for your support, but I understand that you are very busy people. If you could connect me with a blog or resource, explaining this in detail, I would be great forever. Thanks for taking the time to read this. To summarize, I want to do the following.

  • Create my web shell project using asp.net web forms (without Silverlight or any client technology).
  • Create my modules that exist inside their own projects that contain my pages with aspx and aspx code, as well as any dependent assemblies
  • I want these pages to be exportable and importable by my shell.
  • If possible, I would like my module assemblies to be in their own folders so as not to mess up my solution.
+6
source share
2 answers

I did something similar some time ago regarding a plugin system where plugins, where pages and controls were stored in separate assemblies.

As a result, we finished:

Register your custom VirtualPathProvider at Application_Start:

void Application_Start(object sender, EventArgs e) { System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider( new YourCustomVirtualPathProvider()); } 

Override the necessary methods in VirtualPathProvider (based on your logic):

 public class YourCustomVirtualPathProvider : System.Web.Hosting.VirtualPathProvider { private const string RESERVED_PATH = "/components/external"; public override bool FileExists(string virtualPath) { if (virtualPath.StartsWith(RESERVED_PATH)) return true; else return base.FileExists(virtualPath); } public override VirtualFile GetFile(string virtualPath) { if (virtualPath.StartsWith(RESERVED_PATH)) return new MyCustomVirtualFile(virtualPath); else return base.GetFile(virtualPath); } //You'll also need to override methods for directories, omitted for brevity. } 

Now create the MyCustomVirtualFile class to load files from the assembly:

 public class MyCustomVirtualFile : System.Web.Hosting.VirtualFile { private string _virtualPath; public MyCustomVirtualFile(string virtualPath) { _virtualPath = virtualPath } public override System.IO.Stream Open() { //You'll need some method to tie a virtual path to an assembly //Then load the file from the assembly and return as a Stream Assembly assembly = Foo.GetAssemblyByVirtualPath(_virtualPath); string fileName = Foo.GetFileNameFromVirtualPath(_virtualPath); return assembly.GetManifestresourceStream(fileName); } } 

The ASPX / ASCX or resource files that you want to load this way must be added as a built-in resource for the assembly. You can do this by changing the "Create action" property of the file:

properties dialogue

The back code will be compiled into the assembly, and if you use the shared bin folder, you no longer need to do anything. If they are not available, you will need to join the AssemblyResolve and TypeResolve in the global application (more on this here ).

In the end, we abandoned this idea due to security concerns and ended up working with MEF contracts, but if all of your other builds are the first to party, then this should be quick and easy. Hope this helps.

+2
source

Take a look at DotNetNuke . The community version is quite capable and free.

1). This is an open source C # solution without Silverlight. It uses javascript for the client side (but I don't think your requirement is for javascript exception).

2). At the heart of Dotnetnuke is a structure that allows the developer to create modules (there are available starting projects) that connect directly to it. As a developer, you must create a module in a separate project, pack them and deploy them as needed.
There is already a ton of third-party modules.

3). The structure already has a built-in web interface for exporting and importing modules.

4). When the module is installed, it is automatically placed in its own folders.

0
source

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


All Articles