<p>I have an asp.net url path which is being generated in a web form, and is coming out something like "/foo/bar/../bar/path.aspx", and is coming out in the generated html like this too. It should be shortened to "/foo/bar/path.aspx". </p>

<p>Path.Combine didn't fix it. Is there a function to clean this path up? </p>

You could create a helper class which wrapped the UriBuilder class in System.Net
```
```
public static class UriHelper
{       
    public static string NormalizeRelativePath(string path)
    {
        UriBuilder _builder = new UriBuilder("http://localhost");
        builder.Path = path;
        return builder.Uri.AbsolutePath;
    }
}
```
```
which could then be used like this:
```
```
string url = "foo/bar/../bar/path.aspx";
Console.WriteLine(UriHelper.NormalizeRelativePath(url));
```
```
It is a bit hacky but it would work for the specific example you gave.
EDIT: Updated to reflect Andrew's comments.