Xavi Ivars
Xavi Ivars

Reputation: 634

HttpRequest.Url.AbsolutePath vs HttpRequest.Path in .NET

I've been using the HttpRequest class in some legacy code, and I've seen that sometimes the path part is obtained using HttpRequest.Path and some other times using HttpRequest.Uri.AbsolutePath.

I personally don't see any difference between both, but maybe I'm missing something.

Are the results of HttpRequest.Path and HttpRequest.Uri.AbsolutePath always 100% equivalent?

Upvotes: 0

Views: 3393

Answers (3)

John Koerner
John Koerner

Reputation: 38087

Looking at the Reference Source for the Uri, it is built using the Path, so they should be equivalent:

_url = BuildUrl(() => Path);

Upvotes: 1

Krsna
Krsna

Reputation: 11

Yes. They are one and the same. I just run a couple of quick tests and found that the they both are the same. Some research over it showed me that, httprequest.path is an virtual path to the current request which should be exactly the same as absolute path of the URI from that request.

Upvotes: 1

Related Questions