Search code examples
asp.netwebmethod

I use [WebMethod] , just want to ask if this is what they call WebService?


In my C# code behind, I have a WebMethod like this

  //Get total Sales monthly
  [WebMethod]
  public static List<object> getTotalSales(){
     //lines of codes;
  }

My question is, am I doing the thing called web service? I used the returned value in front end (aspx page), which is called by my jQuery ajax function in an aspx file.


Solution

  • You can create a webservice by itself, by creating an .asmx page.

    What you're doing here is turning a public method in your page into a webservice.

    So the short answer to your question, is yes, you're doing a thing called webservice. And you can then call it in your client via ajax.

    This article elaborates on this.