So basically I am looking to grab HTML data from a webpage - the issue is that to access this page one needs to log in. I am already logged in on a browser (IE) but I believe my code doesn't reference the same browser and that's why it requires a log in.
This is what I did so far:
public void HTMLImport(){
string urlAddress = "https://randomWebsite.com/reports/show_report.aspx";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if(response.StatusCode == HttpStatusCode.OK){
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = null;
if(response.CharacterSet == null){
readStream = new StreamReader(receiveStream);
}
else{
readStream = new StreamReader(receiveStream,Encoding.GetEncoding(response.CharacterSet));
}
string data = readStream.ReadToEnd();
response.Close();
readStream.Close();
// This is showing the HTML data for when person is not logged in -
Console.WriteLine(data);
}