What is the use of webservice.asmx
when we are writing all the code in webservice.asmx.cs
? It's just that we are not writing any code on the .asmx
file.
The problem is in old-skool IIS, IIS handles all requests, and it passes requests to other handlers based on the file extension. That means that PNG, JPEG and other files are handled by the static file handler, while ASPX, ASCX, ASMX, SVC, etc. are handled by the ASPNET ISAPI handler.
The registration of the extension is just to tell IIS which handler has to handle the request. That can be changed by mapping all requests to the ASPNET ISAPI handler. You don't really need file extensions then any more, you can just pass the request to the ASMX service handler inside ASP.NET.
From what I understand it is basically an "endpoint" used by IIS, same as .ashx
or .aspx
or .asax
: the directive at the top points to the relevant class(es) in the DLLs in the bin
folder. That's why those files need to be deployed, and not any of the .cs
files.
Here's what Scott Hanselman said in 2005:
It's easy to make the assumption that the ASMX file has some magic and that everything needs to go in it. But the ASMX is just an endpoint like an ASPX or ASMX. It gives IIS and ASP.NET something to think about, but it's just a broker - even less - it's a front.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With