I have helper method which is only checking if User is Authenticated but its generating error
Helper method
public static bool IsLoggedIn(this HtmlHelper helper)
{
return helper.ViewContext.HttpContext.Request.IsAuthenticated;
}
View
@if (GH.IsLoggedIn) //Error is on this line
{
<div class="sign-text" >Signed In As @GH.IdentityName </div>
}
Error
Compiler Error Message: CS0428: Cannot convert method group 'IsLoggedIn' to non-delegate type 'bool'. Did you intend to invoke the method?
Anyone tell me whats the problem.
Why woudn’t you call it like this
@if (Html.IsLoggedIn()) { .. }…
You may want to make this method render appropriate HTML instead of doing
@if (...)check in your view.Then insert it into your view this way: