Enable ASP.NET ASMX web service for HTTP POST / GET requests

Dean Bates picture Dean Bates · Mar 6, 2009 · Viewed 145k times · Source

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

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

.. to the machine.config or web.config. My question is can HTTP POST and GET requests be enabled per web service or web method level rather than per application or machine?

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

Answer

tanathos picture tanathos · Mar 6, 2009

Try to declare UseHttpGet over your method.

[ScriptMethod(UseHttpGet = true)]
public string HelloWorld()
{
    return "Hello World";
}