开发者

When to use a webservice, page Method?

Just starting with JQuery. I have a couple of questions

  1. When to use webmethods ,webservices , page methods , ashx files in an ASP.NET 2.0 website ?

  2. If I were designing an application where I'd use the webmethods on multiple p开发者_如何学JAVAages should I replace them with a webservice ?

  3. I suppose they all do the same thing but when to use which approach?

Thanks, Damien.


I don't use PageMethods anymore, but WebServices as it gives you a clean way to work with the data that you request. It also gives you the ability to use the data in other ways and in other places.

Have a look at http://api.jquery.com/jQuery.ajax/

To be more specific to your questions. 1. I might be bias, but since iv'e starting using asp.net mvc (I know you are using asp.net 2.0 WebForms), but it gives you a better feeling of separation of concerns and cleaner design. PageMethods feels ugly for some reason right now. So, I'd personally advise against it and go with WebServices

  1. If you are using a method in more than 1 page and it's generally to get data from an external provider such as a database or another webservice, it's best to extract this method into a webservice.

  2. The approach I take is to think ahead just a little bit and don't over engineer. Keeps things simple and clean.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜