I am unable to find the difference between HttpContext.Request.Path and HttpContext.GetEndpoint(), and when to use one over the other?
Please suggest.
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.
>Solution :
HttpContext.GetEndpoint()
It returns an Endpoint object which represents a logical endpoint. It allows you to access DisplayName, RequestDelegate and MetaData as well.
HttpContext.Request.Path
The .Request is an HttpRequest which allows to access several information (Protocol, Method, etc.) about the incoming request. Path points to the resource part of the URL.
Comparison
Former allows you to access information about the processing of the incoming request. In other words how your ASP.NET Core application maps the request to your processing logic.
Latter is still ASP.NET Core specific but less about processing. It allows you to scrutinize the incoming request in a structured way.