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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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..
hi! maybe the path is not correct. try

<asp:ServiceReference Path="WebService1.asmx" />
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.


<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].

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Srinivas_VengalaAuthor Commented:
Thanks guys for your suggestions.. I am implementing them in my web application.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.