Working on a site crawler for keeping offline disaster communications files up to date. It was working fine until I added a new site. My other sites list a path to an HTML page such as "https://www.scc-ares-races.org/aresraces.htm". I am trying to point to another site that does not use pages like that, the urls are just to the site or folder with no HTML file specified.
Trying to use the code below to try and open that site generates an exception. How does one work around this?
Using .Net 5 in a WPF application targeting Win7 (to allow most people to use)
The site comes up fine on the same machine I am developing on in Edge and Firefox
using System.Net;
using System.Windows;
namespace WebRequester
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ClickMe_Click(object sender, RoutedEventArgs e)
{
try
{
WebRequest myWebRequest;
WebResponse myWebResponse;
myWebRequest = WebRequest.Create(@"https://www.specsnet.org/");
myWebResponse = myWebRequest.GetResponse();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.InnerException.InnerException.Message.ToString() ,ex.Message ) ;
}
}
}
}
Exception details:
EX: An error occurred while sending the request.
IE: The response ended prematurely.
What I have tried:
1: Tried bumping up the WebRequest timeout. Got to 50x default, same error.
2; To eliminate funky code issues I created a new WPF application with a single button that ran the four lines above. Using that code in example now.
3: Trying targeting different OS versions with no change.
4: Changed WebResponse to HttpWebResponse. No change in behaviour.