Solved

Detecting HTTP redirect

Posted on 2009-04-01
1
287 Views
Last Modified: 2013-12-17
Hello,

How can I request a web site and detect if it redirects to another url?
for example i want to put the url in a textbox if the url return redirect then I get something like:

HTTP/1.1 302 Found
Location: http://redirected.com
I want to store this in variables so that I know where does the URL redirects to.

I  need sample code in asp.net c#

Thanks

Zaki
0
Comment
Question by:zaki100
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
The following should do what you need:
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.hotmail.com");

    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
 

    string finalUri = resp.ResponseUri.ToString();

    resp.Close();

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

772 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

12 Experts available now in Live!

Get 1:1 Help Now