开发者

Does ASP.net use MVP pattern through code-behind code?

开发者 https://www.devze.com 2022-12-18 18:08 出处:网络
I read somewhere on the internet that ASP.net automatically implements MVP pattern with its code-behind page technique. Can anybody tell me w开发者_JAVA技巧hy it is considered as implementing MVP patt

I read somewhere on the internet that ASP.net automatically implements MVP pattern with its code-behind page technique. Can anybody tell me w开发者_JAVA技巧hy it is considered as implementing MVP pattern when I cannot see any Presenter class?


ASP.NET Web Forms, assuming Web Forms specifically is what was intended in the question, does not explicitly implement MVP. It is identified as MVP because MVP is the easiest way to describe the ways in which the platform functions and behaves when compared to ASP.NET MVC.

It is described as MVP because the page's code-behind manages the application logic on the whole. The page's code-behind manages the view at usually the most granular level, it manages the application flow, and it manages the data directly. Whereas, with for example MVC, the view correlates with the model more directly and the middle piece only needs to allow the model and the view to "handshake". Business logic is maintained in the models, user interaction is managed by the view, and the controller manages application flow without consuming fundamental application logic. These differences allow the view to be more testable by swapping out the controllers and models, and the models and their business logic to be testable by swapping out the controllers and views.


No, ASP.NET itself does not offer any sort of presentation/view separation. However, it is possible to apply a standard WinForms style MVP pattern to an ASP.NET page. Here is an example:

http://www.codeproject.com/KB/architecture/ModelViewPresenter.aspx

You can also check out ASP.NET MVC.


You misunderstood what you read. ASP.NET doesn't implement any such pattern.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号