Very Urgent!!! 302 Found and HttpWebRequest

  • Thread starter Thread starter Guest
  • Start date Start date
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...
 
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.
 
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.
--
 
Back
Top