locked
HttpHandler and AJAX RRS feed

  • Question

  • User199626794 posted

    Hi all

    I've just read a chapter about HttpHandlers and because they don't follow the normal life cycle of a page I was wondering if this would be a good candidate to process AJAX calls in combination with jQuery, for example just like the old ASP. I know there are other ways to do this, like callbacks and webservices, but I'm curious about his.

    Sunday, November 4, 2012 2:47 PM

Answers

  • User1779161005 posted

    If you're using MVC then I'd just implement my Ajax callbacks in MVC action methods as it's easier to manage the request there. If yu're building this API for other applications to consume then I'd suggest looking into WebAPI instead.

    Your question seemed to be coming from a web forms perspective, so I didn't mention MVC or WebAPI. Also from WebForms you can build .aspx services or WCF services to handle Ajax calls. The http hanlder gives you more control but is more work. If you want the runtime to do all the serialization for you, then an asmx service is easy enough to implement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 5, 2012 8:45 AM

All replies

  • User1779161005 posted

    HttpHandlers are a fine way to do this.

    Sunday, November 4, 2012 4:17 PM
  • User199626794 posted

    Does the use of an HttpHandler has any benefits in regard to the other methods ?

    Monday, November 5, 2012 2:37 AM
  • User1779161005 posted

    If you're using MVC then I'd just implement my Ajax callbacks in MVC action methods as it's easier to manage the request there. If yu're building this API for other applications to consume then I'd suggest looking into WebAPI instead.

    Your question seemed to be coming from a web forms perspective, so I didn't mention MVC or WebAPI. Also from WebForms you can build .aspx services or WCF services to handle Ajax calls. The http hanlder gives you more control but is more work. If you want the runtime to do all the serialization for you, then an asmx service is easy enough to implement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 5, 2012 8:45 AM
  • User199626794 posted

    BrockAllen, thanks for the reply.

    I'm aware that I could use WebServices but in my mind I linked WebServices to provide access to some functions of our site via an external source. For that reason I thought a WebService wouldn't be the most optimal choice for an AJAX call. 

    Monday, November 5, 2012 10:03 AM