I’m building an ASP.NET website that will act as a “framework” and display information about some services that are running on the web server. One of the things that the site needs to do is serve up custom configuration pages for some modules that have been loaded by the service. The modules will all implement a common API, so there is no concern there — my concern is how can I get configuration pages, which are unique to each module, served up by a common front end?
The pages need to validate user input, handle button clicks, etc. So it’s not as simple as having a method on each module:
public string getHTMLConfigPage()
That would only work if the module’s config page didn’t require user input. In this case, all of the modules will require some form of configuration, at the very least a checkbox indicating “turn on/off”
Here’s the ideal use case:
- At run time the IIS process talks to the back end service and figures out there are N modules running
- The server adds links for these N # modules to a drop down menu
- When the user clicks the menu item for a module, the module’s configuration page is displayed
- The user configures the module however they wish, with the individual module controlling that entire sequence
We’ve already implemented this successfully in C# winforms. The way we did it there was to have each module implement a method public void showConfigDialog(IWin32Window parent);. That works well for a regular desktop app — but obviously doesn’t help me do anything with the web server.
The only thing that I have thought of so far is to have each module also install some stuff onto the IIS web server, and then just do an iFrame where the main “framework” page can display the module’s page in the frame (or a popup window), but that seems messy in that the module developer has to then include some kind of setup scripts to put stuff into the IIS space…
So – is there a better way to do this, or is the iFrame method the only way?
Systen Details:
- ASP.NET 4.0
- C# .NET 4.0
- IIS 7.5 (Server 2008 R2)
EDIT: Additional Details
I have also thought about having the modules place a special ASP.NET DLL in a directory that ASP.NET will probe at runtime. But the root of the problem remains — how can the DLL provided by module get integrated into the main set of web pages? The main set of web pages have a Site.Master page that provides some required items (CSS, menu bar, some jQuery addons, etc.). The DLLs from the modules will likely need this information plus a named pipe that the main web pages use to talk back to an underlying windows service we have written.
It sounds like you need a plug-in framework for ASP.NET. You could achieve this by using MEF (Managed Extensibility Framework) which will allow you to put the complex pages and configuration into a plug-in and load it at runtime; or so I believe.
Start by checking out a Code Project article here, and there maybe the MSDN example here.