ASP.NET MVP和AJAX发布/ web服务 [英] ASP.NET MVP and AJAX posting/webservices

查看:84
本文介绍了ASP.NET MVP和AJAX发布/ web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用M​​VP模式到ASP.NET应用程序,哪里使用AJAX发布数据拟合?对我所知道的MVP模式,用户界面​​很简单,(外观),和所有繁重的在presenter完成。我看不出你如何能遵循的模式,仍然使用AJAX与客户端上的Web服务交互。有没有人有任何引用,如何可以使用AJAX和Web服务,仍然遵循MVP模式?

When applying the MVP pattern to ASP.NET applications, where does using AJAX to post data fit? Of what I know of the MVP pattern, the UI is simply that(appearance), and all the heavy lifting is done in the presenter. I don't see how you could follow the pattern and still use AJAX interacting with web services on the client. Does anyone have any references as to how one can use AJAX and web services and still follow the MVP pattern?

谢谢!

推荐答案

我用的AJAX作为一个普通的ASP.Net回发同样的做法。视图接收后,但其传递到presenter处理的处理。在视图我只是解析来自AJAX传来的请求,然后调用在presenter类的适当方法。

I use the same approach with AJAX as with a regular ASP.Net post back. 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.

Web服务可被视为一个观点,即呈现的消息,而不是渲染HTML。予治疗web服务作为视图,并使用一个presenter相同的方式与ASPX页,与我不需要解析请求的附加优点。

A web service can be considered as a view that "renders" a message instead of rendering 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服务创建从由presenter分配视图数据返回消息的责任presenter。输入消息也只在web服务级别已知

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. The input message is also known only at the web service level.

这篇关于ASP.NET MVP和AJAX发布/ web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆