title: How to generate txt file then force download in ASP.NET Web Forms?
body: <p>I need to set a handler to <code>&lt;asp:Button&gt;</code> element. When user clicks, txt file must be generated in code-behind and must be automatically downloaded by user. There is no need to get any data from user. All file content will be generated in code behind. For example, how to return to user a txt file with content of this variable:</p>
  
  <pre><code>string s = "Some text.\nSecond line.";
  </code></pre>