Enable ASP.NET ASMX Web Service for POST / GET HTTP Requests

I would like to enable the ASP.NET classic web service (ASMX) for POST and GET HTTP requests. I understand that this can be done at the machine or application level by adding ...

<webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> 

.. to the machine.config or web.config file. My question is: can HTTP POST and GET requests be included on the web service or web method layer, and not on the application or machine?

My web service is written in C # using net 3.5sp1.

+56
web-services asmx
Mar 06 '09 at 13:44
source share
2 answers

Try declaring UseHttpGet over your method.

 [ScriptMethod(UseHttpGet = true)] public string HelloWorld() { return "Hello World"; } 
+42
Mar 06 '09 at 14:08
source

Actually, I found a somewhat fancy way to do this. Add the protocol to your web.config, but inside the location element. Specify the web service location as a path attribute, for example:

 <location path="YourWebservice.asmx"> <system.web> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> </system.web> </location> 
+36
Mar 21 '11 at 11:52
source



All Articles