I'm developing custom AuthorizeAttribute with MVC5. I want to check if user is allowed to access an action or not. on selection/click of a link system should check if user is authorized to access the link or not. In case user is not authorized then keep user on same view and display the authorization message in a popup.
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
if (!IsOwner(filterContext))
{
filterContext.Controller.TempData["Authorisedmessage"] = "You do not have sufficient privileges for this operation.";
var currentpageUrl = HttpContext.Current.Request.UrlReferrer;
filterContext.RequestContext.HttpContext.Response.Redirect(currentpageUrl.ToString(), true);
}
}
it keeps user on same page but gives error in @Html.AntiForgeryToken placed on the page.
what is to be done to cater this situation.