With the similarities, there are some differences:
- Page Methods are Public, Static methods located in the page's class file or in it's <Script Runat=Server> tag.
- PageMethods are scoped to just the local page. You cannot call a page method of a different page than what you are currently on. (I'm needing to test this further.)
- Web Services methods allow for a better separation of presentation and control than what a normal code behind structure can provide.
- You cannot reference a WebService method that is in a different domain than the page. (Cross Domain Scripting has security issues that many modern browsers just shut down now).
With two different technologies, which is the better one to use inside of your application?
For the PageMethods model:
- Best for smaller projects
- If time is critical, Page Methods are faster to develop then the WebService Model
For the WebService model:
- When the same code is needed in multiple locations.
- Separation of the control logic is desired
- Projects are larger and tends to find multiple developers working amongst each other's code
In the next post, I'll provide some code snippets on how to get started on each of these technologies.