Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use a page method versus creating a web service?

Tags:

Our team is trying to figure out some guidelines for using pagemethods vs. creating an actual asmx web service. Seems to me that pagemethods are primarily for one off type calls that are specific to the page, where as asmx are intended are intended represents more of a reusable set of operations and services. Does this sound correct?

like image 532
Rob Avatar asked May 01 '09 15:05

Rob


2 Answers

Yes. If yo intend to have something thats going to be used by multiple application it is wise to create it as a separate service, so you are not repeating code between applications and also if have to change you change in a single place.

Simple example, If you have lets say a authentication need, and you have 2 app, one web and one windows. If the user base is going to be the same, it does not make sense to go in the Web App create an authentication code/page, the go to you windows app, and do the same all over again. The reason is, what if have to change the hash code for exemple, you would have to go to the web change it, then go to windows change it, and also redeploy window, now if you have a service, you go to the service change it, and everything now works with the new model, and a big plus, you don't have to redeploy the windows app.

Thats all folks...

like image 70
Oakcool Avatar answered Oct 05 '22 14:10

Oakcool


Even if you're only working on one page and the functionality in question is only used on that one page, sometimes it's better to move the functionality to a separate web service for performance. i recently worked on a page that would make hundreds of calls to a single page method. i noticed a huge increase in performance when i moved it off to a web service simply because you're not dealing with the entire lifecycle of the page. if you're doing something small though, use page methods to keep everything simple.

Update: ArmedMonkey is correct and page methods do NOT go through the page life cycle.

like image 38
gehsekky Avatar answered Oct 05 '22 12:10

gehsekky