Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:17:43+00:00 2026-06-09T16:17:43+00:00

I have an ASP.NET web application that calls a web service on a remote

  • 0

I have an ASP.NET web application that calls a web service on a remote server. I want the application to be able to detect when it is not able to access the web service because of any sort of failure on the remote server.

It is essential that the application can differentiate between a failure on the remote server and a failure due to other circumstances. For example, it must be able to detect the difference between the web service url having been blocked by a firewall and the Http service on the remote server being unavailable.

Can anyone suggest a way of doing this, please? Ideally the solution will use the HttpStatusCode returned on the HttpWebResponse object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:17:44+00:00Added an answer on June 9, 2026 at 4:17 pm

    Put a try clause around the code that calls the remote server and then catch a WebException. Inside the WebException object will be a HttpWebResponse with the status code and other tasty information about the response from the remote server.

    try
    {
        var request = (HttpWebRequest)WebRequest.Create("https://remote.service.com/getdata");
        request.Method = "GET";
        HttpWebResponse response = request.GetResponse() as HttpWebResponse
    }
    catch (WebException wx)
    {
        HttpWebResponse webExceptionResponse = (HttpWebResponse)wx.Response;
        var sr = new StreamReader(webExceptionResponse.GetResponseStream(), Encoding.UTF8);
        string jsonResult = sr.ReadToEnd();
        HttpStatusCode status = webExceptionResponse.StatusCode;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net application that calls an Amazon Web Service to start a
I have an ASP.NET MVC web application that makes REST style web service calls
I have an ASP.NET application that calls other web services through SSL (outside the
I have a C# Windows Service and an ASP.NET 4.0 web application that are,
I have an ASP.NET web application that presents data retrieved from a web service.
I have an ASP.NET web application that calls a .NET DLL, that in turn
Background We have an asp.net 4.0 web application written in C# that calls a
I have a asp.net web application that uses C#. It logs in on a
I have an ASP.NET web application that is using forms authentication. Everything is configured
I have an ASP.NET web application that, for whatever reason, when it is deployed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.