After analyzing the MVC work project, we can compare it with WebForm. We know that the MVC-mode business is placed in the Controller for execution, while the aspx page is only responsible for display. Therefore, the actual service execution time in MVC is advanced to HttpMolde, while the WebForm request is only executed in the httpHandler container. That is to say, ASP is used for the separation of Controller and View in MVC. the Net request pipeline is isolated, which will undoubtedly not affect the efficiency (one request, while Response. redirect is a secondary request.
The advantages of MVC work are obvious, which is more conducive to understanding the layered logic and grasping the code's attention. The process from the Controller to the aspx page has been isolated by the framework. As for the calling process of the Controller, View page, and Model, you still need to be sure. ASP. net mvc framework implements separate management of Controller code.
Looking at the WebForm development model, it is only executed in the HttpHandler container and layered. It lacks support in big aspects and can only be logically separated. It does not mean that they cannot be separated, but by some limitations. The interception of HttpHandler is related to the access suffix. When a page is requested, it is a Handler, and the WebForm model achieves display and logic separation, only the WinForm event-driven. Obviously, events must be registered to pages, such as code such as button#click. The Page_Load method is executed before the button#click operation.
The display code is written into the Page_Load method, which causes additional waste code to be written, such as if (! Page. IsPostBack. The part to be displayed after the execution of the button#click operation is more difficult to handle. Writing another method is also required to be called in the button#click operation. The alternative solution is to use Response. Redirect to process the logic on an aspx page. After the processing, the page jumps to another displayed page. The disadvantage of this is that it is difficult to share data between two pages, and the jump is achieved by marking 302, so one more request. In addition, you can also use Server. execute, Server. transfer or Context. if the RewritePath processing method is used, the two page transformations are completed on the server side and data can be shared. It can be said that the processing method of the two pages is similar to that of the MVC framework. The disadvantage is that you need to manually configure these retargeting attributes.
From the above analysis, we can see that the MVC framework has a strong advantage, and WebForm is not useless, and it is easier to develop in simple applications. WebForm can also be implemented in the same way as MVC, but it only needs to write more code during processing. In my opinion, the biggest problem encountered when using WebForm to develop layers is the data transfer between pages. In my opinion, I have mastered the application skills (Server. execute, Server. transfer or Context. rewritePath) for development
It can solve the data transmission problem. Compared with ASP. net mvc and WebForm, WebForm is easier to understand and does not produce complicated configurations, which is also a good choice.