Web method overloading is not straight forward in use.
Suppose there are 2 methods in a web service.
public string GetEmployee(int employeeId)
{
string empName = string.Empty;
//write code and get employee name
return empName;
}
[WebMethod]
public string GetEmployee(string emailId)
{
string empName = string.Empty;
//write code and get employee name
return empName;
}
This code will compile successfully but will give error at runtime. Please look at below screen shot.
Also if you are new to web service then don’t forget to change this [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
to
[WebServiceBinding(ConformsTo = WsiProfiles.None)] from top of the page in service code behind.
Related Blogs –