What is the advantage of Generic Handler over ASP.NET Page if we can implement some functionality(Writing XML/JSON data) in both places? In which scenario we should use Generic Handler over
.ASPX pages?
Hello @vinodkpasi! Certainly it has few advantages but most importantly one is if you are planning to output a content type rather than
HTML I mean if it does any specific task without creating
HTML contents, than generic handlers are the perfect choice. Again, it depends on your project task and how do you want to deal with it. Finally performance wise, it has advantage as there are many things skipped in the generic handler in respect to
.ASPX files like session state or events etc. I hope, these help.
Helping others is to provide help to yourself. Mark as answer, if the solution helps.
What is the advantage of Generic Handler over ASP.NET Page if we can implement some functionality(Writing XML/JSON data) in both places? In which scenario we should use Generic Handler over
.ASPX pages?
The following reference docs explains HTTP Handlers and reasons for their use in ASP.NET.
What is the advantage of Generic Handler over ASP.NET Page if we can implement some functionality(Writing XML/JSON data) in both places?
I think the .ashx only deal with the http request, and return the value you want. It dose not take care of the html things.
The .aspx need the deal with the controls, return html which .ashx doesn't.
The .ashx should be faster then .aspx.
vinodkpasi
In which scenario we should use Generic Handler over .ASPX pages?
If you only need to return picture or some text such as xml, JSON, plain text, it's better to use the .ashx.
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
In short ASPX is intended to render a web page user interface while ASHX is a general purpose low level handler that renders whatever you want. As usual it depends on what you want/need.
Member
68 Points
240 Posts
ASHX VS ASPX
Nov 04, 2017 07:26 PM|vinodkpasi|LINK
What is the advantage of Generic Handler over ASP.NET Page if we can implement some functionality(Writing XML/JSON data) in both places? In which scenario we should use Generic Handler over .ASPX pages?
Participant
1779 Points
852 Posts
Re: ASHX VS ASPX
Nov 04, 2017 08:56 PM|TechView|LINK
Hello @vinodkpasi! Certainly it has few advantages but most importantly one is if you are planning to output a content type rather than HTML I mean if it does any specific task without creating HTML contents, than generic handlers are the perfect choice. Again, it depends on your project task and how do you want to deal with it. Finally performance wise, it has advantage as there are many things skipped in the generic handler in respect to .ASPX files like session state or events etc. I hope, these help.
TechView
All-Star
52201 Points
23274 Posts
Re: ASHX VS ASPX
Nov 05, 2017 02:42 PM|mgebhard|LINK
The following reference docs explains HTTP Handlers and reasons for their use in ASP.NET.
https://msdn.microsoft.com/en-us/library/bb398986.aspx
Contributor
2260 Points
815 Posts
Re: ASHX VS ASPX
Nov 06, 2017 09:25 AM|Billy Liu|LINK
Hi vinodkpasi,
I think the .ashx only deal with the http request, and return the value you want. It dose not take care of the html things.
The .aspx need the deal with the controls, return html which .ashx doesn't.
The .ashx should be faster then .aspx.
If you only need to return picture or some text such as xml, JSON, plain text, it's better to use the .ashx.
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
All-Star
48290 Points
17997 Posts
Re: ASHX VS ASPX
Nov 06, 2017 10:24 AM|PatriceSc|LINK
Hi,
In short ASPX is intended to render a web page user interface while ASHX is a general purpose low level handler that renders whatever you want. As usual it depends on what you want/need.
If this is a general purpose web api you could also use https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms
If the service is consumed by a particular page it might still make sense to use "page methods": http://www.tugberkugurlu.com/archive/asp-net-web-forms---calling-web-service-page-methods-using-jquery
ASHX is at a lower level and you'll process entirely the request yourself (for example serving files from a db)...