Preface
The purpose of this article is to summarize some things to help friends better use this framework. However, I did not translate the advantages and functions listed on the official website to list them here. Therefore, I 'd like to comment on this framework from my personal point of view. If not, please correct your criticism.
ASP. net mvc -- the product of spiral progress
Why does Microsoft release asp. net MVC, which we cannot know. Maybe it is because of struts on the javaee platform, maybe because MVC is too popular. Maybe Microsoft wants to improve its web app platform, in short, we can only guess. However, it would be interesting to review the evolution of Microsoft's web app platform.
ASP -- Microsoft's earliest contribution to web development may be ASP. This dynamic language makes dynamic web page development more difficult than ever. However, when many people are excited to use ASP to write one dynamic web page after another, its disadvantages gradually become exposed: the language is too simple, without object-oriented support, good ide support, dynamic scripts, and static html, Making modification and maintenance extremely difficult.
Web form-to be honest, even from the current perspective, the web form programming model launched by Microsoft is indeed very creative and practical. Microsoft pioneered the development of desktop applications into Web Application Development: Drag controls, write event processing, and running... everything is so beautiful, and the static code in the previous section is completely isolated from the back-end program in two files, and you can use it. any language on the Net Platform for backend programming. For programmers, using C # for programming is much more comfortable than using ASP. Therefore, the web form model can be said to be synonymous with. NET web app development. All Web developers Based on. NET platforms are familiar with and accept this model.
ASP. net mvc-Microsoft launched ASP. net mvc when web form became popular. Strictly speaking, Asp. net MVC and web form are not comparable. Web form is a complete new model, from the top layer to the bottom layer is a complete set of things, while ASP. net MVC is just a MVC coat for web form. It should be a programming method model Extension Based on Web form. However, from the perspective of developers, Asp. the launch of net MVC has indeed greatly changed our development methods. Many web forms are not recommended (you can still use them because ASP. net MVC is also based on Web
Form). For example, the server-side control that has been praised has been abandoned again, and the client control has been used again. The event-driven model has been abandoned and the traditional URL jump processing model has been used. In addition, data verification and other methods have greatly changed with the methods advocated by web form.
In this case, it seems like a reincarnation, and ASP. net MVC brings us back to the ASP era: server-side models are not used, event-driven mechanisms are not used, and desktop apps are not used for development... we seem to have returned to the traditional ASP era from web form. But is that true? Of course not!
You just need to use it a little bit, you will know that although ASP. net MVC advocates us to abolish many things and habits under Web form, but it is not to let us "return to the original". If we have to say it is a cycle, it should also be said that it is a spiral cycle, is a rising cycle.
Remember that there is a classic proposition in Marxist Philosophy: for new things, the road is tortuous and the future is bright. Perhaps the development of the web app model proves this point. Maybe, server-side controls and event-driven models are not suitable for Web apps at the beginning. Microsoft has taken many detours and has now found the right direction. We need to abandon what we thought we were used to and put into a lot of painstaking efforts. However, after a thing is denied, the rest is a new thing, is a better thing.
For example, we have abandoned the server-side controls and event-driven models that have been used for many years ...... However, we have gained a low-coupling new web model that focuses on the isolated MVC model. You must dare to deny it before you can get a new student. Microsoft is. So are we.
Changes brought about by ASP. NET MVC
Next, let's take a look at what ASP. net mvc denies? What else can be obtained.
1. Form Controls on the server side.
Because ASP. net MVC, server-side form controls are no longer recommended for use, such as our text box, no longer use ASP: Textbox, but use traditional input, or directly let HTML. textbox generation. In short, many server-side controls have been abolished. Even the old friends like gridview that once brought us infinite pleasure are no longer recommended for use. However, it does not mean that we cannot use any server-side controls. For example, to implement the master, our contentplaceholder must still be used.
2. event-driven model.
Since Form Controls on the server are no longer recommended for use, the event-driven model is naturally not recommended. The two are inherently complementary. In ASP. net MVC, when a button is clicked, you should not habitually think of the corresponding Aspx. there is a time processing method in CS. You should think of an action in a controller to handle this event. In fact, in ASP. net mvc, we recommend that you do not write any logic code in Aspx. CS. Even when they do not exist.
3. Data Binding
For structured table data, you must be used to the data binding of the gridview. However, since you use ASP. net mvc, This is not promoted. You should process data display by yourself. Of course, we can also look forward to a powerful helper in the official ASP. net mvc version to help us with data display.
Benefits of ASP. NET MVC
You must know what we can get if we have paid such a terrible price for using ASP. NET? In my opinion, you get at least the following:
1. Clear and focus on Separated code;
2. Easier testing and maintenance;
3. More MVC-compliant presentation layer;
4. You can proudly say to Java programmers: I am using the MVC mode now, and I don't need to write any XML!
Summary
Now, this series is over.
In the beginning of this series, I once said that the only purpose of this series is to keep ASP. net MVC friends outside quick start, Quick Start, quickly learn to use this framework for applications, so this series has been written under the guiding ideology of "practical. It is not comprehensive and does not involve all aspects of ASP. net mvc. However, I believe that now you have the ability to learn those "aspects" on your own. Of course, it is not in-depth enough to explain the underlying principles. However, you can also study the principle of the base class based on practical experience.
In short, as long as you can use this series of articles, learn to use the basic methods of ASP. net mvc, and have begun to try demo. Then, my goal is achieved.
This article is from Zhang Yang's blog T2's notebook