WebMethod is used to access web service method - ASP.NET Introduction

Q.  If you want to access a web service method, which attribute it must have?
- Published on 19 Oct 15

a. [WebMethod]
b. [PageMetod]
c. [Web.Service]
d. [WebSupport]

ANSWER: [WebMethod]
 
A web service is a web-based functionality that is used by other web application.
WebMethod attribute is used with methods within an XML Web service. This attribute makes the method callable from remote Web clients.

Example:
[WebMethod()]

public int Add(int a, int b)
{
return (a + b);
}

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)