HttpWebRequest detect redirect

Posted on 2007-07-26
Last Modified: 2013-11-22

I am opening a URL with .NET HttpWebRequest. I want to detect if the url redirects to another page, and if so, what is the address that it redirects to.

Question by:zattz
    LVL 20

    Accepted Solution

    how about this?

                HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create("");
                HttpWebResponse wresp = (HttpWebResponse)wr.GetResponse();

                if (wresp.ResponseUri == wr.RequestUri)

    Author Comment


    That's just what I needed. And so simple too lol.
    LVL 20

    Expert Comment

    glad I could help. :-)


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now