3

I'm working with a legacy ASP.NET WebForms application, I can't really migrate it to ASP.NET MVC, so I decided to at least divide the application a bit and get things a more organized, I got a nice little ORM and added a Model layer, so now I have aspx files, as my Views, and the Code-Behind as somewhat a Controller, and my separate project, which is a class library, as the Model layer.

Is there a reccommended design patter which is simple and easy to implement for ASP.NET WebForms?

3
  • 7
    Simple and easy is relative. To WebForms adherents, what you're doing is making things harder on yourself. WebForms is an event-driven model, which is quite different than MVC. If you've got an MVC mindset, WebForms is going to frustrate you no matter what you do, and vice-versa. Not saying either is better, but by trying to make one fit to the other mindset is a recipe for headaches and the urge to rip tufts of hair from your scalp. Commented Oct 15, 2012 at 20:45
  • 1
    The model layer makes things quite nicer, I can use itellisense and queries take only one or two lines, instead of 10, I think It can't get much simpler than this... Commented Oct 15, 2012 at 20:48
  • Hi, I find for me the N-Tier pattern works best when working with WebForms. Read more here: msdn.microsoft.com/en-us/library/bb384570.aspx Commented May 31, 2017 at 12:13

1 Answer 1

2

There are quite a few examples of using MVP design pattern with Web Forms. But if you don't want to go that far and rewrite your existing codebase to fit a specific pattern, just try to extract most of your code from event handlers in aspx files to a separate files or project(s). With a little bit of extra work, you can make a lot of code unit-testable and UI agnostic. This will also ensure, that your aspx files will remain as clean as possible and not bloated with the code, not directly responsible for changing the state of controls, etc.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.