Very Urgent!!! 302 Found and HttpWebRequest

G

Guest

Hi!
I am trying to access an ASP.NET web site programmatically. I use
HttpWebRequest and HttpWebResponse classes. Everything goes well until I come
to a page that sends me a 302 Found response. I need to get Location header
from the response but it seems that HttpWebRequest only gets 200 OK. How can
I access to 302 Found response?
Thanks in advance...
 
G

Guest

Thanks for the quick reply.
I set the AutoAllowRedirect property to true. But I still only get 200 OK. I
use a sniffer and here is the output:

POST /webp/login.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*
Accept-Encoding: gzip, deflate
Host: isube.dbk.com
Referer: https://isube.dbk.com/webp/login.aspx
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .

HTTP/1.1 302 Found
Content-Length: 142
Date: Mon, 28 Mar 2005 11:44:37 GMT
Location: /WebP/index_bireysel.aspx
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Set-Cookie: dbk=SessionID=59E18365B3-1ADB-4964-96FA-38CB9DB9ADDA2005

HTTP/1.1 302 Found
Content-Length: 142
Date: Mon, 28 Mar 2005 11:44:37 GMT
Location: /WebP/index_bireysel.aspx
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Set-Cookie: dbk=SessionID=59E18365B3-1ADB-4964-96FA-38CB9DB9ADDA2005

As you can see from the sniffer output, when explorer posts the values,
server responds with 302 Found. But with my code I can only get 200 OK. Is
there a trick or something else to access those 302 Found responses. I need
the values of "dbk" cookies in 302 response...

Thank you.
 
N

Nick Malik [Microsoft]

If I understand correctly, you want to catch the headers on the auto
redirect. If this is the case, you could turn off the autoredirect flag and
implement that function yourself in code. It is simple to do, and you have
access to all the headers.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top