diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 56480fb..9a2e7e8 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -187,6 +187,8 @@ public static Stream DownloadImage(string url) { using (WebClient client = new()) { + // Set the User-Agent header to mimic a request from a browser + client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); byte[] imageBytes = client.DownloadData(url); return new MemoryStream(imageBytes); } diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml index 3d6a2df..2ed99d0 100644 --- a/Views/Home/Index.cshtml +++ b/Views/Home/Index.cshtml @@ -7,16 +7,16 @@ @{Html.BeginForm("ExportToPDF", "Home", FormMethod.Post); {