I wanted to call a web service that is internal to my asp.net web site project in my javascript code and I wanted to call it using the ASP.Net AJAX instead of the usual XMLHttpRequest stuff. So here is what I found. In-order to acheive this lets create a simple web site project and add a very basic service. Lets name it as HelloService (HelloService.asmx). Add a simple web method GetMessage which will accept an integer input and return a string type. Your HelloService.asmx.cs should look like this. using System.Web.Script.Services; namespace MyServices { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, // using ASP.NET AJAX. [ScriptService] public class HelloService : Syste...
Welcome to learn from my learnings. This is where I share my learnings so that others can benefit too and I can reference it in future. I publish posts, helpful notes or cheat sheets on various software technologies.
Abhy Nadar. Sr. Architect @ 3Pillar Global.