I'm having a little trouble with relative URIs
I have a simple HttpListener app that is listening in on a given prefix (currently it is http://+:80/Temporary_Listen_Addresses/, but it could be any other valid prefix).
For a any given request, I'm trying to work out what the requested URI is relative to that prefix, so for example if someone requested http://localhost/Temporary_Listen_Addresses/test.html
, I want to get test.html
.
What's the best way to do this?
Update: The MakeRelativeUri method didn't work for me as it doesn't know about equivalent addresses. For example, the following worked fine when using "localhost":
Uri baseUri = new Uri("http://localhost/Temporary_Listen_Addresses/");
Uri relative = baseUri.MakeRelativeUri(uri);
However it doesn't work if you browse to http://127.0.0.1/ , or http://machinename/ etc...