Is it ok to use HttpRequestMessage.properties in .net core 3.1?

Nishi-nishi 21 Reputation points
2021-12-21T22:36:00.037+00:00

Hi,
I'm using HttpRequestMessage properties property in order to pass auth type in the request so that the message habdler will generate the correct authorization heade (basic, jwt, etc...)
Is it good approach?

Another thing I saw the Properties marked as Obsolet "Use options instead"
But I cannot find the Options property, so I wandered since which version is obsolete? And is it safe to keep usinfg it in .net core 3.1?

Thaks

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | .NET Runtime
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-12-22T08:36:58.867+00:00

    Hi @Nishi-nishi ,

    I'm using HttpRequestMessage properties property in order to pass auth type in the request so that the message habdler will generate the correct authorization heade (basic, jwt, etc...)
    Is it good approach?

    You can use the HttpRequestMessage properties to add the authorization header in the Asp.net core 3.1 application, it is OK. Refer to the official document: Make HTTP requests using IHttpClientFactory in ASP.NET Core.

    Another thing I saw the Properties marked as Obsolet "Use options instead"

    You may be viewing the latest version of the document, you can check the following screenshot, the document is for the .Net 6, but if you check the "Applies to" part, this property still applies to Asp.net core 3.1.

    159619-image.png

    If you want to view the .Net Core 3.1 version document, you can change the .Net Version or see this link.

    159597-image.png

    To the HttpRequestMessage.Options Property, we can see this property applies to Asp.net 5 and Asp.net 6, instead of Asp.net Core 3.1:

    159671-image.png


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.