Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

differences between doing ajax using a page method, a web service and a custom http handler

Tags:

c#

ajax

asp.net

I'm looking to create json objects in the client and then transfer these objects back to the server for processing. These are the following options I'm considering:

  • a page method

  • a web service

  • a custom http handler

I'm looking to use jquery to send the objects. The plan is to convert the json object into c# objects that in turn go into queries. During the processing, I'll need access to the users' session that's working in SQL server session mode. The pages where these calls will be running will be on https. The return objects will also be json objects. I'll consider scalability, security and performance.

I was wondering what would be the ups/downs of using each option.

Thanks for your suggestions.

like image 231
frenchie Avatar asked Jul 06 '11 23:07

frenchie


1 Answers

This is my order of preference:

  • web service
  • httpHandler (asp.net web services are httpHandlers behind the scenes)
  • page method

Web service gives the maximum flexibility and scalability. ASP.Net web services are in fact HttpHandlers conforming to XML/SOAP standards.

Page Methods are least flexible. They best for one off communication between a piece of javascript with the aspx page. Even then, you have better ways to handle that rather than going through a page method.

Here are few benefits of using a web service:

  • Standards based
  • Provide loose coupling between systems
  • Can be scaled easily
  • Provide greater security as you can implement security at many levels (Authorization, Authentication wise)
like image 142
Mrchief Avatar answered Oct 06 '22 00:10

Mrchief