views:

39

answers:

3

Hello,

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, 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.

A: 

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.

InSane
Thanks for the idea, I have tried with MEF, but it wasn`t clear for me when involving page or many pages as a part of the plugin. I came with a solution using the .Net MVC2 platform that I put in an answer of the question.
VasilP
A: 

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.

Adrian K
I did all the cases on paper before so it is clear for me what has to be done. The problem for me was, with the idea of webforms, when we request some of the webpages that was copied with plugin, how it will identify the basic application because it will run its assemly, more ... checking the licenses and if the logged user can use this plugin. Also using the master page is tricky.
VasilP
A: 

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 :)

VasilP