Я хочу использовать зарегистрированную информацию пользователей во всех видах. У меня есть пользовательский класс 'CustomUserSM' для сериализации / десериализации как заявки.
public class CustomUserSM
{
public bool Authenticated = false;
public string Username { get; set; }
public string Name { get; set; }
public byte userCountryId { get; set; }
public int userCityId { get; set; }
etc..
}
Я добавил ниже строки в _ViewImports
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor
@inherits ProjectName.Auth.BaseView<TModel>
Класс BaseView здесь;
public abstract class BaseView<TModel> : RazorPage<TModel>
{
private readonly IHttpContextAccessor _httpContextAccessor;
public readonly CustomUserSM UserInfo;
public BaseView(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
if (_httpContextAccessor != null)
{
if (_httpContextAccessor.HttpContext.User.Claims.Any(c => c.Type == "Info"))
{
UserInfo = JsonConvert.DeserializeObject<CustomUserSM>(_httpContextAccessor.HttpContext.User.Claims.First(c => c.Type == "Info").Value);
}
}
}
}
эта строка уже добавлена в Startup.cs
services.AddHttpContextAccessor();
.. и я получаю эту ошибку;
There is no argument given that corresponds to the required formal parameter 'httpContextAccessor' of 'BaseView<dynamic>.BaseView(IHttpContextAccessor)'
Чего мне не хватает? Заранее спасибо.