Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I try to download the page as html the pages does not hold the session and takes you back to the login page. How do I pass the HttpCookie to the HttpWebRequest for validation?
Or can it work with a session? The code works on a page that does not have a login session.

I already created the the encrypted cookie on login.
I just need to know how to read the cookie so HttpWebRequest knows the user is validated.


C#
HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(this.Page.Request.Url.ToString());
  myWebRequest.Method = "GET";
  myWebRequest.AllowAutoRedirect = false;

  // make request for web page
  HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse();
                    
  StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream());

  string myPageSource = string.Empty;
  myPageSource = myWebSource.ReadToEnd();

  myWebResponse.Close();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900