Best way to abort/cancel action and response from ActionFilter

后端 未结 6 1650
清歌不尽
清歌不尽 2020-12-24 13:51

Best way to abort/cancel action from ActionFilter

I\'ve got this ActionFilter, and it\'s suppose to end the connection immediately and return a 401 Unau

6条回答
  •  鱼传尺愫
    2020-12-24 14:22

    using .net core 2.1 the solutions above did not work for me , so i tried this and it worked :-

     context.HttpContext.Response.StatusCode = 401;
     return;
    

    if there is better solutions for .net core 2.1 i am open for suggestions

提交回复
热议问题