I’m checking via $.post function if user is authenticated. If not, I want to redirect him to the login page and also put the current url in the ?RedirectUrl= parameter (the same way like the FormsAuthentication.RedirectToLoginPage() does). Hot to do it ? Via Jquery or some .net method ?
I’m checking via $.post function if user is authenticated. If not, I want to
Share
You can create your custom AuthorizeUser attribute and override HandleUnauthorizeUser(..).
Then you can verify is request is ajax request then return a jsonresult with proper value,which can be read by javascript in the view.
Try following code.( I have not tested yet)
use it instead of [Authorize] attribute in controller actions.