Let's compare the Web Service (asmx) and Handler (ashx):
- With Web Service you can run your Visual Studio and add the web service as web reference. This will create the necessary classes for you. With web service, the serialization and deserialization of the data object will be handle by .Net framework. This simply means that you can work with Web Service without having deep knowledge in the "background" process.
- With Handler you must find out what is the parameter to be pass to the handler. No code generator that is able to help out over here. It provides very basic features to serve the request and you will have to serialize/deserialize your data objects manually (you may use JavaScriptSerializer to deal with the JSON data). It does not limit you from returning the data in JSON, XML or CSV format. It's all depend on your design.
There is no conclusion on which one is better. It goes back to you to choose which one is suitable for the project that you work on.
I have a question. Can you use generic asp .net handler for file transfer? I have a project, where I have a client run as windows service. Client will upload/download files from client computer to/from server every n minutes. On server side I want to make ashx which will process request and download/upload file. And it will do other things too, depends on type of request (delete file from server, compute hash of file, rename file, etc.)
ReplyDeleteTo handle file transfer efficiently, you may have to use FTP or WCF. This is because both ASMX and ASHX are relying on HTTP/HTTPS which is not efficient when handing binary data.
DeleteIn your case, you may consider develop a WCF solution and enable TCP protocol.
Yes. But in my project I have a demand that it needs to use HTTP/HTTPS protocol. So I need to stuck to WCF?
ReplyDeleteYou may configure WCF to use HTTP/HTTPS or TCP protocol. It's quite straight forward in changing the config file with the WCF Config tool.
DeleteI really enjoyed reading post, big fan. Keep up the work andplease tell me when can you publish more articles or where can I read more on the subject?
ReplyDeletevideo and blog marketing
this post help me more clear. Thanks
ReplyDeleteThanks and I have a tremendous proposal: Where To Start House Remodeling split level kitchen remodel
ReplyDelete