public static class HttpContextExtenssions { public static async Task RefreshLoginAsync(this HttpContext context) { if (context.User == null) return;
Then use it in your controller
[HttpPost("[action]")] [Authorize] public async Task<IActionResult> Validate() { await HttpContext.RefreshLoginAsync(); }
Or draw it in the action filter
public class RefreshLoginAttribute : ActionFilterAttribute { public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { await context.HttpContext.RefreshLoginAsync(); await next(); } }
Then use it in your controller
[HttpPost("[action]")] [Authorize] [RefreshLogin]
Tseng source share