PDA

View Full Version : MVC Pattern in ASP.Net


Princess
18th August 2008, 07:18 PM
I know there is a simple answer and I'm probably just making it too hard for myself, but I don't know how to implement an MVC pattern in ASP.Net.

I can't use Monorail, ASP.Net MVC, or any other well-developed MVC framework because none of them are compatible with the environment I'm working with. Specifically, I'm writing plugins for DotNetNuke, and I haven't found any MVC framework that plays well with DNNs. I'm pretty much compelled to implement this pattern by hand, and I'm not sure how to approach the problem.



In general, I don't like ASP.Net's codebehind approach (a page controller pattern) because it makes no distinction between view and controller, so its very hard to test. In very high level terms, I'm trying to do something like this:

- I want my view (the user control) to be as stupid as possible. I don't want any business logic in my pages at all. The view is responsible for spitting out HTML and nothing more.

- I also want my model to be as stupid as possible. It only represents the data before its spat out to the browser, and its defined in a seperate Models dll .

- I want my controller to be smart, but completely oblivious to the existence of the view. The controller only changes to the model, and it might respond to changes in the view through some event handlers. The controller would be defined in own DLL, seperate from Models and Views.


I apologize if this is a somewhat broad question, but how is an MVC pattern implemented in ASP.Net by hand? I'm not really asking for code, just a few nudges in the right direction because I'm just not sure how to fit all of the pieces together and make them talk to one another transparently.