title: How to get/read text file from a url using C#?
body: <p>I'm trying to read text from URL:<br>
  <a href="https://whitworthpirates.com/services/schedule_txt.ashx?schedule=139" rel="nofollow noreferrer">https://whitworthpirates.com/services/schedule_txt.ashx?schedule=139</a></p>
  <p>Here's my code:-</p>
  <pre><code>     var webRequest = WebRequest.Create(SourceUrl);
  
              var response = webRequest.GetResponse();
              var content = response.GetResponseStream();
             
               using (var reader = new StreamReader(content))
               {
                  string strContent = reader.ReadToEnd();
                   HttpContext.Current.Response.Write(&quot;Read: &quot;+strContent+&quot;&lt;br /&gt;&quot;);
               }
              HttpContext.Current.Response.Flush();
              HttpContext.Current.Response.End();
  
  </code></pre>
  <p>HttpContext.Current.Response.Write prints out nothing. I've tried the same code with <a href="https://google.com" rel="nofollow noreferrer">https://google.com</a> and StackOverflow webpages and it gets the text from these sites just fine.</p>
  <p>I've also tried to download the file from the same URL using the following code:-</p>
  <pre><code>WebClient webClient = new WebClient();
  webClient.DownloadFile(url, @&quot;c:\myfile.txt&quot;);
  </code></pre>
  <p>It managed to download a .txt file on my server but it is an empty file with a size of 0KB.</p>
  <p>Can someone help me with this, please?</p>