How To: Consume ASP.NET Webmethod in AngularJS

There are many queries related to how ASP.NET webmethod can be consumed in AngularJS.

The post demonstrate how to do it.

The solution is attached with has samples that show how this can be done

In Sample 1: Webmethod returns a string 

In Sample 2: Webmethod returns a list of the ids that are retrieved from the database using very basic code to serialize object to JSON( uses: DataContractJsonSerializer)

In Sample 3: Webmethod takes id as the input and retrives the string(name) from the database

The data returned from webmethod is then consumed by AngularJS

Demo code location: Sample Code

Note:

Sample code is developed using Visual Studio 2013, Sql Server 2008R2.

Use applicable best practises in the real world applications for AngularJS/WebMethods

No Comments