在Global.asax中添加方法
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) {
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null) {
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
var serializer = new JavaScriptSerializer();
var serializeModel = serializer.Deserialize<CustomPrincipalSerializeModel>(authTicket.UserData);
if (serializeModel != null) {
var newUser = new CustomPrincipal(HttpContext.Current.User.Identity);
newUser.TeacherId = serializeModel.TeacherId;
newUser.SchoolId = serializeModel.SchoolId;