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 8856015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:15:53+00:00 2026-06-14T14:15:53+00:00

I am using WebClient to get some info from a page that is sometimes

  • 0

I am using WebClient to get some info from a page that is sometimes not available [302 Moved Temporarily]. So i want to program to detect whether the page exists

I tried to override the WebClient WebResponse with the following code to only return the page when it’s status is OK but it did not worked.

protected override WebResponse GetWebResponse(WebRequest request)
{
    var response = base.GetWebResponse(request);

    if (response is HttpWebResponse)
        return (response as HttpWebResponse).StatusCode == HttpStatusCode.OK ? response : null;
    return null;
}

when i used my overriden class to get the page (when it is unavailable) it just redirected and did not returned null

Get code

private async Task<string> Get(string uri)
{
    return await Handler.DownloadStringTaskAsync(new Uri(uri));
}

[WHAT I WANT TO ACHIEVE] : i want the web client tried to get the page but it was not found so it has been redirected to another page.

  • 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-14T14:15:54+00:00Added an answer on June 14, 2026 at 2:15 pm

    This won’t tell you the status but it can be inferred by the fact that you were redirected.

    if(reponse.ResponseUri != request.RequestUri) {
       // if you really want to know the status
       // set AllowAutoRedirect = false;
       // and send another request in here.
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my code, I'm using a System.Net.WebClient to get individual files from an SVN
In my app I am downloading some MP3s from the Internet using WebClient .
I have Windows Forms Application that Updates its GUI from a website using WebClient's
I want to upload file to a host by using WebClient class. I also
The following call returns a result in WinXP but not on Win7: using (WebClient
I've got some code which downloads some RSS feeds. I've been using WebClient or
I am using the WebClient.DownloadString() method to download some data. I am using the
I am using the WebClient class to post some data to a web form.
I'm trying to get the html content of a page using silverlight. Webresponse and
I want to know when some parallel tasks are completed. I'm using this code

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.