This is a warning that the VirtualPathUtility class in .Net 2.0 takes
some time to understand the rules under which it operates. It
wasn’t obvious to me, and I had to do some investigation to learn it’s
behavior. I expected the following test to pass. It didn’t.
public void ShouldCombineTwoWebsitePaths()
string parentPath = “/websiteRoot”;
string subDirectory = “newPage”;
string expected = “/websiteRoot/newPage”;
string actual = VirtualPathUtility.Combine(parentPath, subDirectory);
I expected it to actually “Combine” the base path and the path that was
relative to the base path. After all, if these combine, the
product will be the sum of both, right? Not really. Here’s
my test output:
String lengths differ. Expected length=20, but was length=8.
Strings differ at index 1.
Thanks to the first comment below, I realized that this method
tries to act like a web browser in resolving relative paths. If I
add a “/” to the end of “/websiteRoot”, the test would have
passed. As it stands, it assumes that “websiteRoot” is a page and not