简体   繁体   English

ASP.NET MVP和AJAX发布/ Web服务

[英]ASP.NET MVP and AJAX posting/webservices

When applying the MVP pattern to ASP.NET applications, where does using AJAX to post data fit? 将MVP模式应用于ASP.NET应用程序时,使用AJAX发布数据在哪里适合? Of what I know of the MVP pattern, the UI is simply that(appearance), and all the heavy lifting is done in the presenter. 在我所知道的MVP模式中,UI只是外观(外观),所有繁重的工作都在演示者中完成。 I don't see how you could follow the pattern and still use AJAX interacting with web services on the client. 我看不到如何遵循该模式,仍然使用AJAX与客户端上的Web服务进行交互。 Does anyone have any references as to how one can use AJAX and web services and still follow the MVP pattern? 是否有人对如何使用AJAX和Web服务并仍然遵循MVP模式有任何参考?

Thanks! 谢谢!

I use the same approach with AJAX as with a regular ASP.Net post back. 我对AJAX使用的方法与常规ASP.Net回发相同。 The view receives the post but passes it to the presenter that handles the processing. 该视图接收该帖子,但将其传递给负责处理的演示者。 In the view I just parse the request coming from AJAX and then invoke the appropriate method on the Presenter class. 在视图中,我只是解析来自AJAX的请求,然后在Presenter类上调用适当的方法。

A web service can be considered as a view that "renders" a message instead of rendering HTML. Web服务可以看作是“渲染”消息而不是呈现HTML的视图。 I treat the web service as the view and use a presenter the same way as with an ASPX page, with the added advantage that I don't need to parse the request. 我将Web服务视为视图,并以与ASPX页面相同的方式使用演示者,其附加优点是不需要解析请求。

I decouple the presenter from the message leaving for the web service the responsibility of creating the return message from the view data assigned by the presenter. 我将演示者与消息分离开来,以使Web服务负责根据演示者分配的视图数据创建返回消息。 The input message is also known only at the web service level. 输入消息也仅在Web服务级别是已知的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM