title: ASP.Net Validating Culture Names
body: <p>We have a multilingual site that utilizes asp.net 2.0 cultures.  The current culture is set through the url rewritten as a query string.  (~/es/blah.aspx is the spanish version of ~/blah.aspx - rewritten as ~/blah.aspx?lang=es)</p>
  
  <p>The code that tests the culture is as follows:</p>
  
  <pre><code>    System.Globalization.CultureInfo ci;
      try
      {
          ci = new System.Globalization.CultureInfo(Request.QueryString["lang"] ?? string.Empty);
      }
      catch
      {
          ci = new System.Globalization.CultureInfo(string.Empty);
      }
  </code></pre>
  
  <p>If there is no culture set, it defaults to english, 127.  When there is a culture, all links on that page are then pre-pended with the correct culture name.</p>
  
  <p>Some how or another a spider got a hold of a few links in the form of ~/www.test.com/blah.aspx and is hammering our site with a culture of www.test.com which and flooding our error logging.</p>
  
  <p>Is there any way to test whether a culture name is valid besides catching an exception?</p>