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)
The code that tests the culture is as follows:
System.Globalization.CultureInfo ci;
try
{
ci = new System.Globalization.CultureInfo(Request.QueryString["lang"] ?? string.Empty);
}
catch
{
ci = new System.Globalization.CultureInfo(string.Empty);
}
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.
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.
Is there any way to test whether a culture name is valid besides catching an exception?