0

I have developed a webapplication in both ASP.NET MVC and ASP.NET Webforms and i'm wondering isn't Webforms following the rules of the MVC Pattern just the as ASP.NET MVC is?

I mean we have the .aspx file which holds the visual (HTML and JavaScript) and then the code behind file which controls the user interaction and data for the .aspx file. Then we could make a Repository lager for fetching and doing stuff with data.

Isn't this the same as following the rules of the MVC Pattern? View for visual, Controller for controlling user interaction and data for the Views and the Model fetching and doing stuff with data?

I know ASP.NET MVC and Webforms handles Postbacks and URL handeling differently, but im not comparing the two ASP.NET techniques, but the MVC Pattern in generele for the two techniques.

3 Answers 3

3

ASP.NET Webforms is definitely not following the MVC pattern.

In MVC you have three elements, the Model, the View, and the Controller.

In ASP.NET Webforms, you have your Page (codebehind and the markup are compiled into a single object, not seperate), and whatever data is being shown. You really have no controller. You make a requrest directly to the page rather than a controller and the page is responsible for both working with the data and rendering the page. Definitely not seperated like MVC would be.

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

2 Comments

Thanks. Just the answer i was looking for.
Not sure I 100% agree with this answer. There is nothing forcing you to have the page "work with the data" or do anything with the data other than display and return user input. You may make a request directly to the page, but you don't have to make the page do anything with that request other than pass it on to your controller which in the case of an MVC pattern is just a separate class.
0

Just the fact that you're not using the codebehind in your aspx page should give you a hint that there are some pretty substantial differences between MVC and webforms... You aren't using the codebehind, are you?

Not to mention how hard it is to test a Webforms page.... You are testing your code, right?

1 Comment

This is not an answer to the question: you are only giving some hints.
0

You can indeed use an MVC pattern with Web Forms, but all you are doing is adding additional classes or layers to the postback. The previous answers here are coming from a purist point of view that is more clear separations built into the technology. But, there is nothing preventing you from using different classes to represent the Model the View and Controller and only have your WebForms bind to the View. All of the communication is still done on postback, but it is still technically MVC and still the correct pattern to use.

Reference: http://msdn.microsoft.com/en-us/magazine/ff955232.aspx

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.