You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when the client is not logged in yet, the cookies from the container are only checked if also the RestoreCookies method is set in the Client options. This ignores the cookies that may already be stored and valid inside the registered CookieContainer
Why is this a problem?
If the client is injected in a scoped service, the service will always receive a new instance where LoggedIn is set to false. This causes the client to make an extra call to the auth page even if valid cookies are already present.
What should be changed?
The CookieContainer can be checked for valid cookies even if RestoreCookies method is not set. Then the existing logic can be applied to determine whether the client is already logged in or not.
This may need an additional check for the lifetime of the cookie to prevent sending an expired cookie in the requests.
The text was updated successfully, but these errors were encountered:
@AdrianJSClark working like a charm. The HttpClient automatically stores the Cookies in the container and the client stays logged in without the need to do anything else.
Why is there a need to change?
Currently when the client is not logged in yet, the cookies from the container are only checked if also the
RestoreCookies
method is set in the Client options. This ignores the cookies that may already be stored and valid inside the registeredCookieContainer
Why is this a problem?
If the client is injected in a scoped service, the service will always receive a new instance where LoggedIn is set to false. This causes the client to make an extra call to the auth page even if valid cookies are already present.
What should be changed?
The
CookieContainer
can be checked for valid cookies even ifRestoreCookies
method is not set. Then the existing logic can be applied to determine whether the client is already logged in or not.This may need an additional check for the lifetime of the cookie to prevent sending an expired cookie in the requests.
The text was updated successfully, but these errors were encountered: