0

I'm trying to find out if there is a way to use ASP.Net MVC to design a modular web application.

By modular, I mean that I should be able to drop a "package" (which could be made of a bunch of files, I don't necessarily require a single file deployment). The idea is to deploy additional functionality seamlessly. Functionality could go from tweaking the existing web site (that is the easy part, any plugin architecture would do), up to having whole new site areas.

I'm looking for pointers as to - if that is even possible - what choices I have to make w/ regards to view engines for example - any gotchas I should be aware of

I found one or two references, but ASP.Net MVC moves fast and they might be out of sync.

Any input is welcome (up to and including "don't go there") !

2 Answers 2

3

It's easy.

Start with creating a class library with the same structure as a regular MVC project. Make sure that all views are changed to "Embedded" in file properties.

Use an inversion of control container like Autofac and just tell it to register all controllers in all assemblies found in the current directory.

You need to create a custom VirtualPathProvider that looks for your views in all found plugin dlls. You might also want to make the VirtualPathProvider modify the views so that @inherits YouBaseView<TModelName> is added, since Views\Web.Config isn't used for embedded views.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, the VirtualPathProvider information opened up a few roads on google. I think I have some reading to do now :)
I'm using areas in my class libraries. Using them make it a lot easier. You can study my open source project if you want some hints: github.com/jgauffin/griffin.mvccontrib/tree/master/source/…
2

I am thinking about doing something similar, I found this to be a good article to get started: http://sankarsan.wordpress.com/2009/04/12/a-layered-aspnet-mvc-application-part-iv/

What I have done so far is opt for the Castle Windsor IoC container - information about ASP .NET MVC and Windsor is here: http://stw.castleproject.org/Windsor.Windsor-tutorial-ASP-NET-MVC-3-application-To-be-Seen.ashx

I then use the Razor Generator from here: http://razorgenerator.codeplex.com/ so that I can compile views into separate assemblies.

And some code from here: https://github.com/csteeg/BoC/blob/master/Src/Commons.Web.PrecompiledViews to build a view engine that uses the IoC container.

With those two things and a few interfaces that are custom to my application I have been able to drop in "modules" by putting DLLs into a folder and have them appear as tabs within the hosting application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.