Exposing Web Services to Client Script in ASP.NET Ajax Web Applications

I have a .NET Web Application . I have created a web service and trying to access the web methods in the webservice like below mentioned in aspx:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">    
     <asp:ServiceReference Path="~/WebService1.asmx" />
function jsAjaxCall() {
//do javascript function
but it is throwing an error saying MyNamespace.MyApplication.WebService1 is null or not an object.
It is working fine in Web site but not in web applilcation.(problem with class files I believe in WEB APPLICATIONS)
I am creating a Web Service - WebService1.asmx.cs file; but in web application since there is no App_Code, it is not recognising the webservice file.
Can anyone suggest how to create & access web service through Client Script in ASP.NET Ajax WEB APPLICATIONS.
Who is Participating?
Hi! Check your web service if script is allowed

    public class DataService : System.Web.Services.WebService

Open in new window

Srinivas_VengalaAuthor Commented:
Yes script is allowed...
When I call the webservice method... it is not going to the web service file itself..
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

hi! maybe the path is not correct. try

<asp:ServiceReference Path="WebService1.asmx" />

<asp:ServiceReference Path="http://localhost/WebService/Service1.asmx" />
Srinivas_VengalaAuthor Commented:
I have tried with that option also but getting the.. same error : null or not an object !.

I am sure problem is with creating a webservice as asmx.cs(classfile) in web application and including in the directory.
If we need to include a class file .. we can create a dll and add reference .. but is there a way we can do for asmx.cs files also?

Yes you can reference the asmx in your web application. Right click your web application then select add web reference. Theres an option there [Web Services in this Solution].
Srinivas_VengalaAuthor Commented:
Thanks guys for your suggestions.. I am implementing them in my web application.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.