Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am unable to find the difference between HttpContext.Request.Path and HttpContext.GetEndpoint, and when to use what?

Please suggest.

What I have tried:

Searched a lot on google, looks like they both do the same thing (return the endpoint url) but not clear why there are 2 ways to get the same result, and when should I use one over the other.
Posted
Updated 2-Mar-24 5:59am
v2

1 solution

The request pathe returns a simple string, detailing the path. GetEndpoint is an extension that returns the underlying Endpoint[^]. So, if you want to be able to explore the underlying metadata of the request, use GetEndpoint. If all you need is the path, use Request.Path.
 
Share this answer
 
Comments
Wild-Programmer 4-Mar-24 13:12pm    
Thank you so much 🙏
Pete O'Hanlon 4-Mar-24 14:09pm    
You are most welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900