?
Solved

HttpWebRequest detect redirect

Posted on 2007-07-26
3
Medium Priority
?
1,244 Views
Last Modified: 2013-11-22
Hi,

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.

thx
0
Comment
Question by:zattz
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 2000 total points
ID: 19573325
how about this?

            HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create("http://www.msn.com");
            HttpWebResponse wresp = (HttpWebResponse)wr.GetResponse();

            if (wresp.ResponseUri == wr.RequestUri)
            {
                //Yes
            }
            else
            {
                //No
            }
0
 

Author Comment

by:zattz
ID: 19573403
Thanks!

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

Expert Comment

by:REA_ANDREW
ID: 19573420
glad I could help. :-)

Andrew
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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