Hi Lehel,
Try using this class instead of WebClient:
/// <summary><see cref="System.Net.WebClient" /implementation
/// that does not honor http redirect response status codes.</summary>
public class HttpNonRedirectingWebClient : System.Net.WebClient
{
public HttpNonRedirectingWebClient()
{
}
protected override System.Net.WebRequest GetWebRequest(Uri address)
{
// Allow the base method to create the WebRequest and try to cast it to HttpWebRequest
System.Net.HttpWebRequest request = base.GetWebRequest(address) as System.Net.HttpWebRequest;
if (request == null)
// TODO: create resource string for exception message
throw new ArgumentException("HttpNonRedirectingWebClient requires the address argument to use the http protocol.",
"address");
// ** disable auto-redirection **
request.AllowAutoRedirect = false;
return request;
}
}
--
Dave Sexton
"Lehel Kovach" <le*********@hotmail.comwrote in message news:9Y*******************@tornado.socal.rr.com...
I'm having a problem with the WebClient object. When I post data to certain sites, it will receive a command from the webserver
(object moved) and continue to the next link by downloading that. The problem is, certain cookies need to be set, and the only
way of doing that is not letting the WebClient automatically go on to the next GET in the background--I need to do it manually.
I'm wondering if this has something to do with the Connection: Keep-Alive header. If this is the case, how do I change it?
Because, everytime I tamper with this header, WebClient.UploadData doesn't work anymore.