I am using jQuery to load a usercontrol dynamically from server side code. Currently my server side code resides in HttpHandler. We all know there can a WebMethod too embedded inside an aspx page which can be used to obtain same functionality.
Just wanted to know the difference using HttpHandler vs WebMethod. What I got to know while searching the web is that, Webmethods embedded in aspx files have an overhead where-in the page methods are also called. Can anyone help me comparing the two with
respect to page life cycle being executed every time when using webmethods. Or any other performance gain using httphandler vs webmethod.
Also what I read is that using httphandler we have less overhead while returning data. Can anyone help me pointing to an article in this regards. Thanks in advance.
jquery ajax call page method
AJ Please don't forget to click “Mark as Answer” on the post that helped you.
I used the webmethod and after my user control got rendered, I tried to check the page view source for any kind of additional javascript. I could not find any. What type of javascript is getting added. Can you please elaborate?
AJ Please don't forget to click “Mark as Answer” on the post that helped you.
PageMethods behave as web services, but offer a bit more capabilities than a web service. Unlike a full postback (i.e. UpdatePanel) which will incurr the overhead of processing the full ASP.NET pipeline, a PageMethod has a bit of a truncated pipeline that
sets up the context, but bypasses all the rest of the event chain required for a full page postback. An HttpHandler is like a Page (in fact, a Page is an HttpHandler), and as such it will require the full event chain to be fired. A PageMethod is pretty much
the most efficient way to perform an AJAX call that requires Session and HttpContext access, but not Request/Response access. A WebService
might be faster, but there is SOAP overhead that could hurt performance.
Given that HttpHandlers and WebServices require a bit more work to write than a PageMethod, and the extra processing cost for both, PageMethods are generally the best solution when a full postback (async via UpdatePanel or not) is not needed.
Hope this will helps
Please mark the answer if it helps you.
Ramani Sandeep (My Blog)
(MCTS, MCC-2011)
Thanks for the reply. But all these articles point to ways in which I can use jQuery with webmethods / httphandlers. What I am looking for is the difference when using one over the other.
AJ Please don't forget to click “Mark as Answer” on the post that helped you.
Does that mean since my scenario has just request response values of my user control string, httphandlers would be more viable to use? If i use webmethod, full postback will occur of page c
sandy060583
PageMethods behave as web services, but offer a bit more capabilities than a web service. Unlike a full postback (i.e. UpdatePanel) which will incurr the overhead of processing the full ASP.NET pipeline, a PageMethod has a bit of a truncated pipeline that
sets up the context, but bypasses all the rest of the event chain required for a full page postback. An HttpHandler is like a Page (in fact, a Page is an HttpHandler), and as such it will require the full event chain to be fired. A PageMethod is pretty much
the most efficient way to perform an AJAX call that requires Session and HttpContext access, but not Request/Response access. A WebService
might be faster, but there is SOAP overhead that could hurt performance.
Given that HttpHandlers and WebServices require a bit more work to write than a PageMethod, and the extra processing cost for both, PageMethods are generally the best solution when a full postback (async via UpdatePanel or not) is not needed.
Hope this will helps
ycle?
AJ Please don't forget to click “Mark as Answer” on the post that helped you.
I am using jQuery to load a usercontrol dynamically from server side code. Currently my server side code resides in HttpHandler. We all know there can a WebMethod too embedded inside an aspx page which can be used to obtain same functionality.
Just wanted to know the difference using HttpHandler vs WebMethod. What I got to know while searching the web is that, Webmethods embedded in aspx files have an overhead where-in the page methods are also called. Can anyone help me comparing the two with
respect to page life cycle being executed every time when using webmethods. Or any other performance gain using httphandler vs webmethod.
Also what I read is that using httphandler we have less overhead while returning data. Can anyone help me pointing to an article in this regards. Thanks in advance.
To answer your question, "page methods" have absolutely none of the overhead of the page life cycle. They are basically a shorthand for defining ASMX "ScriptServices".
Raw HttpHandlers will always be one of the fastest choices, but ASMX/WCF services and page methods are very fast too. It takes significant traffic volume before you notice any difference between any of them.
ashishnjain
Member
168 Points
98 Posts
HttpHandler vs WebMethods with jQuery
Apr 08, 2010 04:27 AM|LINK
I am using jQuery to load a usercontrol dynamically from server side code. Currently my server side code resides in HttpHandler. We all know there can a WebMethod too embedded inside an aspx page which can be used to obtain same functionality.
Just wanted to know the difference using HttpHandler vs WebMethod. What I got to know while searching the web is that, Webmethods embedded in aspx files have an overhead where-in the page methods are also called. Can anyone help me comparing the two with respect to page life cycle being executed every time when using webmethods. Or any other performance gain using httphandler vs webmethod.
Also what I read is that using httphandler we have less overhead while returning data. Can anyone help me pointing to an article in this regards. Thanks in advance.
jquery ajax call page method
Please don't forget to click “Mark as Answer” on the post that helped you.
HerryAtHotma...
Participant
1481 Points
259 Posts
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 04:57 AM|LINK
Hi.
1) "WebMethod" wiil add some javascript automatically on the page in assence to call it from JQuery/javascript.
2) you can call "HttpHandler" directly from JQuery/javascript using "xmlHttp" or "Jquery.Ajax".
so, if you are using JQuery then it is batter to use "HttpHandler" to avoid OverHead of javascript injected by asp.net for calling "WebMethod".
Hope this will help.
thanks.
jquery asp.net
Das.Sandeep
Star
10652 Points
1897 Posts
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 05:02 AM|LINK
http://stackoverflow.com/questions/608006/where-am-i-going-wrong-in-calling-asmx-web-methods-from-jquery
http://stackoverflow.com/questions/1525313/help-me-understand-web-methods
http://www.codeproject.com/KB/webservices/jsonwebservice.aspx
http://randomactsofcoding.blogspot.com/2009/03/jquery-json-and-asmx-20-services.html
Please give us feedback no matter whether you get your answer.
Please "Mark as Answer" if it's useful for you.
Regards,
Sandeep
ashishnjain
Member
168 Points
98 Posts
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 05:12 AM|LINK
I used the webmethod and after my user control got rendered, I tried to check the page view source for any kind of additional javascript. I could not find any. What type of javascript is getting added. Can you please elaborate?
Please don't forget to click “Mark as Answer” on the post that helped you.
sandy060583
Star
8714 Points
1624 Posts
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 05:15 AM|LINK
PageMethods behave as web services, but offer a bit more capabilities than a web service. Unlike a full postback (i.e. UpdatePanel) which will incurr the overhead of processing the full ASP.NET pipeline, a PageMethod has a bit of a truncated pipeline that sets up the context, but bypasses all the rest of the event chain required for a full page postback. An HttpHandler is like a Page (in fact, a Page is an HttpHandler), and as such it will require the full event chain to be fired. A PageMethod is pretty much the most efficient way to perform an AJAX call that requires Session and HttpContext access, but not Request/Response access. A WebService might be faster, but there is SOAP overhead that could hurt performance.
Given that HttpHandlers and WebServices require a bit more work to write than a PageMethod, and the extra processing cost for both, PageMethods are generally the best solution when a full postback (async via UpdatePanel or not) is not needed.
Hope this will helps
Ramani Sandeep (My Blog)
(MCTS, MCC-2011)
ashishnjain
Member
168 Points
98 Posts
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 05:16 AM|LINK
@Sandeep,
Thanks for the reply. But all these articles point to ways in which I can use jQuery with webmethods / httphandlers. What I am looking for is the difference when using one over the other.
Please don't forget to click “Mark as Answer” on the post that helped you.
ashishnjain
Member
168 Points
98 Posts
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 05:41 AM|LINK
@Sandy
Does that mean since my scenario has just request response values of my user control string, httphandlers would be more viable to use? If i use webmethod, full postback will occur of page c
ycle?Please don't forget to click “Mark as Answer” on the post that helped you.
gt1329a
All-Star
15377 Points
2501 Posts
ASPInsiders
MVP
Re: HttpHandler vs WebMethods with jQuery
Apr 08, 2010 05:55 AM|LINK
To answer your question, "page methods" have absolutely none of the overhead of the page life cycle. They are basically a shorthand for defining ASMX "ScriptServices".
Raw HttpHandlers will always be one of the fastest choices, but ASMX/WCF services and page methods are very fast too. It takes significant traffic volume before you notice any difference between any of them.
A guide to combining jQuery and ASP.NET: jQuery for the ASP.NET developer