开发者

ASP.Net webforms application with pluginable architecture problem

It was told me to make a pluginable web app. with webforms. The idea is to have one base web application with a plugin host that will load any plugins and related to them web pages.

As an example, I have my MyHostApplication with master page and a default.aspx file. When it is compiled, basically the project will have the files Site.Master and Default.aspx in the main directory and MyHostApplication.dll in "bin/" dir. All plugins will be lets' say in directory "plugins/". Then I create Calculator plugin as a new project with its webpage Calc.aspx in this direcotry and an assembly Calculator.dll in the directory "bin/" ... or with the web.config i may move it somewhere. I can load the assembly in the host application with LoadAssembly and get the main class (which I have as base class and all plugins base classes inherits this class) and get some information from it within the properties, like name, version,开发者_Go百科 postion in the menu, etc.

Now the problem - when I navigate to /plugins/Calculator.aspx (lets' say from the Tools menu that I the plugin host has built) it loads its assembly and doesn't know about the main host application. But it has to go trought the main application. Also it should be best if somehow I can use the Master page of the main application with the plugin page.

Can some give me some help hints here? Thanks in advance.


Not a direct answer to your question but have you explored MEF

It is based on the same principles and could help you get a head start in what you are trying to achieve.


Attributes can be very useful as an integration mechanism.

The approach is pretty simple, basically we want to identify the webforms so that we can dynamically find them; using attributes and reflection gives you a lot of flexibility in terms of solution detail.

First, you need to design (on paper / whiteboard / in your head) a set of attributes that are going to give you what you're after - do you just want to use the attributes to "find" the webforms - or do you want to use them to provide other useful meta data as well?

After that:

  • Develop the actual attributes somewhere appropriate in your system (probably a common library of osme kind).
  • Decorate each WebForm with the attributes
  • Develop a component that uses reflection to locate classes (the webforms) that are decorated with the appropriate attribute(s)
  • Use the data extracted during the reflection to build the navigation.

If you're new to attributes, this tutorial might help.


Thanks for the responses! Finally I get what I was looking for :) ... I saw a tutorial just for my case which is solved with MVC v.2, with suits perfectly for my idea.

It can be found here. It is very basic but it solves the problem with the pages of the plugin and the master page usage, also we can manage the licenses for the plugin and versions very easy. The other thing is that i like jQuery which is closely used with it so the idea work for me :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜