Tuesday, November 16, 2021

Error while calling a web service method(by URL) in asp.net C# and how to call a parameterized web method

 If we get the error in web service while calling web method: 

http://localhost:85/WebService.asmx/HelloWorld

Request format is unrecognized for URL unexpectedly ending in '/HelloWorld'.

(Screenshot below)
We have to add the following code in web.config file.
Calling a parameterized web method by URL where id is parameter 1 and id2 is parameter 2

<configuration>
  <system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>
  </system.web>
</configuration>

Calling a parameterized web method by URL where id is parameter 1 and id2 is parameter 2
http://localhost:85/WebService.asmx/HelloWorld?id=1&id1=2



No comments:

Post a Comment