PathInfo WoesASP.NET introduces a new URI component to the equation: PathInfo. It's not very well known, possibly due to poor implementation and consequent lack of usefulness. However, it is important that you understand how it can affect you. Browsers (and the System.Uri class) only split paths into two pieces: the path and the query string. ASP.NET, however, splits the path once again, into the Request.FilePath and the Request.PathInfo properties. In the following three urls, the page test.aspx is always successfully executed, even though test.aspx is not immediately followed by a question mark. The string between "test.aspx" and "?" is stored in the Request.PathInfo property, and is not used when trying to find the appropriate .aspx file to execute.
|Control.ResolveUrl("test.jpg")(Improper path resolution)||test.jpg||test.jpg||test.jpg|
|Relative path needed by browser||../../test.jpg||../test/jpg||test.jpg|
Side effectsSince PathInfo allows requests like /UrlTests/content/pages/test.aspx/folder/file to still reach test.aspx, most ASP.NET sites can be linked to in a manner that will cause all file references to break. In fact, if a user accidentally types or adds a "/" after any URL ending in .aspx, your site will fall apart. I want my web sites to look and act professional in all situations, so I'm not too fond of Request.PathInfo. However, you can circumvent this issue by using a good URL rewriting library and configuring it correctly. Here are a few sites which break when accessed in this manner
- http://asp.net/default.aspx versus http://asp.net/default.aspx/
- http://silverlight.net/default.aspx versus http://silverlight.net/default.aspx/