[Solved] ASP.Net Core MVC Error: HttpContext doesn not contain a defination for Current

pandeygolu4200
 
on Sep 30, 2022 05:41 AM
606 Views

This is the error i am getting

HttpContext doesn not contain a defination for Current

@if (HttpContext.Current.User.IsInRole("Administrator"))
{
    Html.RenderPartial("AdminMenu");
}
Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Oct 07, 2022 04:47 AM
on Oct 07, 2022 05:09 AM

IHttpContextAccessor need to be injected in the view page.

Refer below article.

ASP.Net Core Razor Pages: Display (Get) Session value in cshtml page