会话:系统混淆同时访问的用户

时间:2016-02-04 12:45:06

标签: c# asp.net-mvc

当两个用户同时访问系统时,它会以某种方式混淆用户,不仅是名称,还有其权限......

我在ActionFilter

中登录后分配会话
public class UserAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        int idUser = new UserBusiness().GetIdByExternalId(decodedToken.ExternalUserId.ToInt32());//Id from goes token
        User user = new UserBusiness().GetById(idUser);
        filterContext.HttpContext.Session["User"] = user;

     }
}

在BaseController中有以下方法来检索会话:

public User GetCurrentUser()
{
    return (User)HttpContext.Session["User"];
}

有没有人遇到会话这个问题?

1 个答案:

答案 0 :(得分:0)

问题出在控制器方法中,如下:

[HttpGet, OutputCache(NoStore = true, Duration = 1)]

我只离开得到并决定(不解释原因):

[HttpGet]