Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to return Unauthorized result in OnActionExecuting method

$
0
0
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
   var authenticateKey = filterContext.HttpContext.Request.Headers["AuthenticateKey"];
   if (String.IsNullOrEmpty(authenticateKey))
   {
       base.OnActionExecuting(filterContext);
   }
   else
   {
       filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized });
//Instead of jsonresult, here I want to return response Unauthorized to browser } }


Viewing all articles
Browse latest Browse all 9386

Trending Articles