title: C# Security: check query string for valid .pdf filename
body: <p>I'm modifying an .aspx page that uses some javascript to download a file based on the value attribute in this tag:</p>
  
  <pre><code>&lt;input type="hidden" id="launchDocument" value="pdf/&lt;%=Settings.LaunchDocument%&gt;" &gt;
  </code></pre>
  
  <p>That value is currently hard-coded into the Web.config file. The client wants this page to now be a download page for their archived newsletters. My thoughts were to have the page pull in the filename from the query string so the sending page could define what file is being downloaded:</p>
  
  <pre><code>&lt;input type="hidden" id="launchDocument" value="../pdf/&lt;%=Request.QueryString["filename"]%&gt;" /&gt;
  </code></pre>
  
  <p>But, I'm concerned whether there is any security risk to this method. If there is, what are the best practices for checking the query string's value to make sure it's a valid .pdf filename before adding it to the page?</p>
  
  <p>Thanks in advance for any help!</p>