I would like to check if a user is logged in in an ASP.NET Core 2.0 application in a Razor page. The following code worked in .NET 4.6.1:
@if (!Request.IsAuthenticated)
{
<p><a href="@Url.Action("Login", "Account")" class="btn btn1-success btn-lg" role="button" area="">Sign In »</a></p>
}
How can I do this in Core 2.0?
Edit: David is right of course.
Just check if
User
orHttpContext.User.Identity.IsAuthenticated
istrue
or not.