How to declare a method as WebMethod?

Raja
Posted by Raja under ASP.NET category on | Views : 7400
To declare a method as WebMethod, write the WebMethod attribute while defining it. It is used to expose a method as Web Service method or make the method accessible from PageMethods in ASP.NET AJAX.

[WebMethod]
public static string GetData(string f, string s)
{
Person p = new Person();
p.Forename = f;
p.Surname = s;
// throw new Exception("Custom Error :) ");
return SerializeObjectIntoJson(p);
}


Thanks

Comments or Responses

Login to post response