public class BaseController : Controller
{
public string UserId { set; get; }
public string AccessToken { set; get; }
private readonly IUnitOfWork _unit;
public BaseController(IUnitOfWork unit)
{
_unit = unit;
}
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
UserId = Session["_UserId"] as string;
AccessToken = Session["_AccessToken"] as string;
// ......
}
}
即使 AccessToken 返回值。UserId 即将到来,null
即使我可以调试并看到Session
对象中有一个值。
我在会话中设置它们:
Session.Add("_UserId", user.Id);
Session.Add("_AccessToken", user.AccessToken);
这是怎么回事?