SO i have some code that accesses the html of a website given it woks but only in visualstudios.Framework for c# when this code is input into the app.config.
<system.net> <defaultProxy useDefaultCredentials="true" /> </system.net>
ps next line between the ><
but i need this code to work in .CORE instead of .FRAMEWORK but it gives this error.
System.Net.WebException: 'The remote server returned an error: (407) Proxy Authentication Required.'
i tried solving it by creating a app.config from the solution explorer , but to no affect did it work all the answers on the internet are either too complicated or it shows that little bit of code i put in the app.config of .FRAMEWORK which does not work on .Core
the code as a starting point.
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);
Console.WriteLine("Sorry , somethings faulty");
}
else
{
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
readStream.ToString();
// Console.WriteLine(readStream);
}
string ImpureTexta = readStream.ReadToEnd().ToString();
BaseHTML = ImpureTexta; ///turns ImpureText in class to the actual html code so it can be used by entire program
Console.WriteLine(BaseHTML);
Console.WriteLine(" <--------------------------------Extraction B Complete --------------------------------->");
}
Thanks