开发者

ajax and security controller

开发者 https://www.devze.com 2023-01-08 19:08 出处:网络
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

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.

  1. Asp MVC [Authorize] to return a Post instead of a Get
  2. More control on ASP.Net MVC's Authorize; to keep AJAX requests AJAXy
0

精彩评论

暂无评论...
验证码 换一张
取 消