What is the most direct way to use AuthorizeAttributeit JsonResulttogether so that when the user is not logged in, the application returns a Json error, not a login page?
AuthorizeAttribute
JsonResult
The two things that I am considering now are expanding AuthorizeAttributeor simply creating a new attribute that implements IAuthorizationFilter.
IAuthorizationFilter
Remove AuthorizeAttributefrom your action.
Then in the first lines of your action, paste this:
if (!User.Identity.IsAuthenticated) return Json("Need to login");
or return any message you want.
Source: https://habr.com/ru/post/1788411/More articles:Interfaces and abstract classes - javaPATH environment variable, what am I doing wrong? - pathHow can I make an element draggable and resizable in jquery? - jqueryR: create a custom installer for windows - rjQuery -diven div, stretch the height of the div to reach the bottom - jqueryHow to create a custom JsonAuthorize attribute to protect actions that return JsonResults? - asp.net-mvc-3jquery - toFixed but not toFixed - javascriptMemory Management Issues NSTimer - memory-managementHow to fix the position of Mdichild forms? - c #Поддержание работоспособности тестирования интеграции базы данных - c#All Articles