Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Difference between HttpContext.Request.Path and HttpContext.GetEndpoint()

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading