FarligOpptreden
Executive Member
- Joined
- Mar 5, 2007
- Messages
- 5,396
So, the past couple of weeks I've been investigating ASP.NET MVC for a very large-scale enterprise web application. I'm all for the idea and methodology, but I've found it quite cumbersome to implement very large-scale, dynamic applications using ASP.NET MVC.
So, just to be different, I decided to implement my own MVC-type framework, based on good old ASP.NET. The version in question is 3.5, but you could very easily implement the same in 2.0. The idea revolves around the following:
That's the basic idea I've been busy implementing, with a basic, working prototype that I managed to build yesterday. This way, I have a lot more freedom in implementing exactly what I want in exactly the way I want, without being limited to web forms in normal ASP.NET, or following the structured route ASP.NET MVC prescribes. Also, using XSLT for View transformations gives me absolute control over the resulting HTML sent back to the client and, if you know your XSLT well enough, you could implement quasi-object-oriented XSLT transformations, including bits and pieces of smaller XSLT files for commonly used entities in your application.
The benefit I found so far for this approach is being able to store different "views" for the same entity in your database and being able to implement new entity views on the fly, without any alteration to the application's code or without the need to recompile and deploy. Sure, you could get the same going using normal ASP.NET MVC, but I just found this XSLT "templating" a lot easier to implement and foresee easier maintenance in the future as well...
Feel free to discuss...
So, just to be different, I decided to implement my own MVC-type framework, based on good old ASP.NET. The version in question is 3.5, but you could very easily implement the same in 2.0. The idea revolves around the following:
- Break up you application into 3 very distinct projects called Model, View and Controller.
- Let your Model project contain all your entity classes, representing your Data Model from your chosen database platform.
- Let your Controller project serialize each entity in the Model project to XML to be transformed with XSLT. Your event handling will also happen in this project. You can access any input submitted by the user by using Request.Form["inputFieldName"]. These would typically be mapped to the properties of the classes exposed in the Model project.
- Your View project would consist of a single page, for argument's sake called "handler.aspx", that would parse an incoming URL and use parameters specified in the query string to call the corresponding object in the Controller project, which would transform the Model's serialized XML to HTML using a specified XSLT file. This resulting HTML would then be sent back through the response stream in the Controller object.
- By specifying an action in your URL, the controller would know what to do with the posted data, like updating the model in the database if a "save" action was passed through the URL.
- You can implement URL rewriting / rerouting through many of the freely available assemblies to achieve nice, friendly URLs, like rerouting http://server/app/entity-type/entity-id/action to http://server/app/handler.aspx?controller=entity-id&type=entity-type&do=action.
That's the basic idea I've been busy implementing, with a basic, working prototype that I managed to build yesterday. This way, I have a lot more freedom in implementing exactly what I want in exactly the way I want, without being limited to web forms in normal ASP.NET, or following the structured route ASP.NET MVC prescribes. Also, using XSLT for View transformations gives me absolute control over the resulting HTML sent back to the client and, if you know your XSLT well enough, you could implement quasi-object-oriented XSLT transformations, including bits and pieces of smaller XSLT files for commonly used entities in your application.
The benefit I found so far for this approach is being able to store different "views" for the same entity in your database and being able to implement new entity views on the fly, without any alteration to the application's code or without the need to recompile and deploy. Sure, you could get the same going using normal ASP.NET MVC, but I just found this XSLT "templating" a lot easier to implement and foresee easier maintenance in the future as well...
Feel free to discuss...
Last edited: