ASP. NET's MVC is what a joke!

Source: Internet
Author: User
A long time ago, I was skeptical about the MVC pattern when I was still dissembling, because I had always been upset about this pattern, which had been hard adapted from the CS structure.
I don't have to go into details about what the MVC model is. I believe many TX products can come along with the same article. But do we have to think about the best practices of this kind of best practices that are not tested well under the CS model on the web?
Anyone familiar with the working principles of the Web knows that the Web application is operating in a standard request-response mode. All requests are sent in the browser, and the requests and operations of the corresponding browser on the server are calculated, the page that generates the result is returned to the browser. However, it is absolutely impossible for the server to send the page without initiating any request from the browser (in the past there was push technology, but it has not been mentioned for a long time ). The MVC mode cannot adopt the push technology in such a working environment, but the view model changes only when there is a request on the page, and then the view is re-painted, instead of proactively notifying all views when the model changes, it would be:

View sends a request to the Controller-> control its operation data according to the request-> controller obtains the data filling model-> controller selects view filling with model-> display view

The difference between such a process and the best practices of the MVC model is unnecessary.
Let's take a look at the process of classic MVC

Event causes the Controller to change the model or view, or change both. As long as the controller changes the data or attributes of models, all dependent views are automatically updated.ClassSimilarly, as long as the controller changes the view, the view will retrieve data from the potential model to refresh itself.

Here we can see the difference: Classic MVC uses events to automatically drive, while web operations are procedural and linear, so I feel awkward when using MVC.
Many times, some other advantages of MVC, such as the separation of logic and interface (struts is indeed done and is not bad), so many people turn a blind eye to this rigid practice, so I personally think, MVC is not the best practice in the Web environment. We can also find a better way. Some frameworks are already trying to change, but the name is still not changed.
----------------------------------------------------------------------
ASP. net, Asp. net implements the event-driven Web programming model. Originally, it was a good opportunity to implement MVC on the Web. However, Microsoft has many shortcomings in its design, there is no clear definition. In 2.0, there was an MVP suggestion, but it was not clearly defined in design (Microsoft's characteristic is that there is a theory behind existing products ). Generally, the ASPX page is treated as a view, and the. CS file of the page is used as a controller. The view is either a class similar to a JavaBean or a dataset (in fact, dataset is a good thing, and my favorite one is it ). In fact, I think it is more reasonable to use usercontrol as a view (I usually do this ). Events are used to concatenate these strings. However, in terms of event settings, I think Microsoft has at least a few points that are not properly configured. One is that the button event occurs after pageload. Logically, button should trigger the button event after it is clicked Code To process the data and change the model. Then, all views can obtain the updated model to refresh the interface. Here, the load event is placed before the button event, which is logically unreasonable, of course, we can think that pageload is used to perform some processing during page initialization. But since the page has remained in the status, why does it load again after clicking the button? At least when I explained this problem with students, I had to talk about the origin of web with patience for a long time. If we wanted to advertise the event-based page programming, we would do something completely, block all the underlying layer. Here we leave a trigger for us to step on the mine to demonstrate that the design was not clear at the beginning. I can see that the pageload function is more uniform, it is executed only when the page is opened for the first time and will not be triggered when there is a PostBack, so that you do not need to use an if statement to create a complex structure, most of the time, in pageload, We need to write a complicated structure to distinguish various situations. I don't know whether it is oo or pasta.

I dare not say that I am proficient in MVC. I just want to give my opinion on my own understanding. Welcome to criticize me by those who are proficient in MVC.

Tital is actually complaining. Recently, karrigell was used to find that there is no need to worry about any request in it. All post items are directly variables, it is directly the parameter of the method, and handle can be combined with multiple parameters in the form of overload methods, presumably in ASP. net. But the idea of pursuing perfection is correct. I hope to see more perfect ASP. NET in 3.0.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.