Actually, the term "mini" isn't accurate. It should be micro, nano or even yocto! But I like the sound of MiniMvc. To give you an idea of how small it is, the project has 7 code files (I like it, seven is the number of perfection), and about 10 classes. You are probably wondering: it can't be good if it has only 10 classes! And, probably the question bugging you more is...
Quick answer: To gradually migrate an old, big project, either in Web Forms or Web Site structure, into the new shiny MVC 3 framework. With MiniMvc you can add some features to your application while keeping the old code running. So, all the new code you write goes into the right place and you can piece by piece move pages into controllers and views.
Basically, it adds the following capabilities to your application:
- URL Routing to route requests to controller methods
- A base Controller class to easy up some repetitive work
- Razor views to render your output (Thanks to RazorEngine)
Which is actually most of what MVC is all about. The models aren't covered just so you can use wherever you want.
-
Add a references to the MiniMvc.dll and RazorEngine.dll
-
Configure the Razor views on your
Web.config
-
Instantiate the MiniMvc inside your Global.asax file like this
VB
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) MiniMvcSystem.GetInstance(System.Reflection.[Assembly].GetExecutingAssembly(), "~/Views") End Sub
C#
void Application_Start(Object sender, EventArgs e) { MiniMvcSystem.GetInstance(System.Reflection.Assembly.GetExecutingAssembly(), "~/Views"); }
Note: the second parameter, if you didn't guess it yet, is your Views folder :)
-
Create
Controllers
andViews
folders. TheControllers
folders can be anywhere, e.g.~/App_Code/Controllers
(if your project is of type Web Site, you have to put the folder somewhere insideApp_Code
. If you used the above config, you have to put the Views folder at the root of your site / application.