ajax and security controller
I'm using jQuery Ajax to post and when success get the data and replace some items that works well if I add some security to the controller like that
[Authorize开发者_JAVA百科]
public ActionResult .........
If the user logged in everything go OK but when the user not logged or not authorized it should be redirected to the login page
As I'm using Ajax and it not ordinary post the user will not redirect to log in a window? What can I do to solve this problem? Or how can I know that the user isn't authorized before post with java to display an alert to tell the user to log in or the role didn't match?
I think these two questions can provide enough info to set you in the right direction.
- Asp MVC [Authorize] to return a Post instead of a Get
- More control on ASP.Net MVC's Authorize; to keep AJAX requests AJAXy
精彩评论