Closed hishamco closed 7 years ago
@DamianEdwards is this fine for you?
No, I don't like using IHttpContextAccessor
.
Strange!! Is there any reason to avoid using IHttpContextAccessor
?
The service doesn't depend on IHttpContext
, it just needs the user.
I injected the IHttpContextAccessor
to access the User
, which is similar to what you did here https://github.com/aspnet/live.asp.net/blob/92d0385e7d1e4e052deba4bbaaf13bacbf9d2d7e/src/live.asp.net/Controllers/HomeController.cs#L27, furthermore I'm not sure why it depends on the ClaimsPrincipals
while the intend is to get the recorded shows
In the example you gave, I grabbed the user from the class I'm already in, so that's not the same. I need the user because I don't allow non-authenticated to bypass the cache.
It uses ControllerBase.User
https://github.com/aspnet/Mvc/blob/1dd1d49321eab65431e9c4b0465d7d9f2b23dbdf/src/Microsoft.AspNetCore.Mvc.Core/ControllerBase.cs#L230, which is the similar thing that I access it via DI
It really isn't :smile:
I got confused 😄
@DamianEdwards your feedback