How to check the availability of a web service before calling it. C#

Posted on 2007-03-23
Medium Priority
Last Modified: 2013-12-17

I would like to check the availability of a web service before calling it through c#. Sort of like a ping.

How would I accomplish this.
Question by:terrorbyte
  • 4
LVL 22

Expert Comment

ID: 18779059
you could use system.net.webrequest / webresponse and check to see if the getresponse method returns null

Author Comment

ID: 18779299
Hi p davis,
how exactly would i do that?
LVL 22

Accepted Solution

p_davis earned 2000 total points
ID: 18780383
WebRequest myRequest = WebRequest.Create(site);
            WebResponse myResponse = myRequest.GetResponse();

where site is the url
LVL 22

Expert Comment

ID: 18781250
also instead of checking for null you would probably want to do some exception handling with a try block
LVL 22

Expert Comment

ID: 18977206
did you get it figured?

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question