I have this code:
class CustomWebclient: WebClient
{
[System.Security.SecuritySafeCritical]
public CustomWebclient(): base()
{
}
public CookieContaine
Your code runs fine under my test.
My test site weibo.com will force redirect by HTTP 302 when proper cookies are provided.
With autoredirect off, the Response Headers are
Transfer-Encoding: chunked
Connection: close
Pramga: no-cache
DPOOL_HEADER: dagda24
Cache-Control: no-cache, must-revalidate
Content-Type: text/html
Date: Thu, 13 Mar 2014 15:07:53 GMT
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: Thu, 13 Mar 2014 15:07:53 GMT
Location: /u/2398332747/home?wvr=5
Server: nginx
and the web page is not redirected obviously.
With autoredirect on, the Response Headers are,
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Pragma: no-cache
DPOOL_HEADER: balor165
Cache-Control: no-cache, must-revalidate
Content-Type: text/html; charset=utf-8
Date: Thu, 13 Mar 2014 15:13:26 GMT
Expires: Sat, 26 Jul 1997 05:00:00 GMT
Server: nginx
the web page contents verifies that the request is redirected.
I do notice that the Location header's first letter is capital. This is not tested whether header format is related.
Edit:
At last, example.com is tested but under my environment it doesn't trigger a redirection at all. That's why i picked weibo.com as the alternative.
Edit:
I did some more research on this and according to RFC 2616, headers are case-insensitive. Your code is fine to me, still don't know why it goes wrong. Hoping someone else give a lead.