Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of webservice.asmx when we are writing all the code in webservice.asmx.cs?

Tags:

c#

asp.net

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.

like image 535
cpr43 Avatar asked Oct 19 '22 15:10

cpr43


2 Answers

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.

like image 88
Patrick Hofman Avatar answered Nov 15 '22 09:11

Patrick Hofman


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.

like image 40
BCdotWEB Avatar answered Nov 15 '22 09:11

BCdotWEB