Just last week, I discovered a long known, highly irritating limitation of ASP.NET with regard to the way it handles pathinfo. Worst of all, the problem is impossible to reproduce locally using the Cassini web server that is build into VisualStudio. After banging my head against the wall, I think I came up with a pretty good solution that worked in my particular example, which I will refer to as "Check Box Hell".
A Little Bit of Background
So, you're all proud of yourself because you managed to build a filtering control in .NET that is easy to use anywhere and can create path info URLs so you can pass along the results of a filter to anyone easily (rather than POSTed). Let's assume the part of your filter tool that does path info stuff looks like this:
// pseudo-ish
string id, value;
string pathInfo = "";
foreach (Control control in wrapperControl.Controls){
id = control.ID;
if (control is TextBox && !string.IsNullOrEmpty(((TextBox)control).Text)){
value = ((TextBox)control).Text;
}
else if (control is DropDownList && ((DropDownList).SelectedIndex > 0){
value = ((DropDownList)control).SelectedValue
}
... // other controls
if (!string.IsNullOrEmpty(value)){
pathInfo += "/" + id + "=" + Server.UrlPathEncode(value);
}
}
It's fairly simple, and it'll create your path segments that look like this: /txtZipCode=19127/drpState=PA. You test the code locally using the VisualStudio Cassini web server and it works like a champ. Then, you deploy it to your staging server and it is broke like a joke. How could this be? Read on for the solution.