Im having a bit of a problem with my C# code and im not sure how to tackle it. Im attempting to DownloadString a webpage that only people that are logged in can see (otherwise it returns a 403 response). So I though the best way to do this was to set the HTTP header cookie value to that of a logged in users. Unfortunately it has not worked. Here's the snippet of code:
WebClient web = new WebClient();
web.Headers[HttpRequestHeader.Accept] = "*/*";
web.Headers[HttpRequestHeader.Cookie] = "User cookie";
string pagecontent = web.DownloadString("Forbidden page");
When the code is used, I still get a 403 error. I am definitely using a working cookie, i've tested it. What could be going wrong?
In addition to that, how would I grab a cookie from a webBrowser and set the webclient HTTP cookie header to that?