I am trying to extract the html of my current page. To do it is pretty simple
private string GetHtml()
{
WebClient myClient = new WebClient();
string myPageHTML = null;
byte[] requestHTML;
// Gets the url of the page
string currentPageUrl = Request.Url.ToString();
UTF8Encoding utf8 = new UTF8Encoding();
requestHTML = myClient.DownloadData(currentPageUrl);
myPageHTML = utf8.GetString(requestHTML);
Response.Write(myPageHTML);
return myPageHTML;
}
But my problem I am having is, if this page is behind a secure section, the WebClient is effectively unauthenticated, so the server will just return the "Login screen" instead.
Can I pass my cookie or my session to this WebClient?