我正在使用服务堆栈 MVC 电源包创建一个 ASP.NET MVC 4 应用程序,并利用服务堆栈的身份验证和会话提供程序。我从社交引导 API 项目中复制了很多逻辑。我的控制器继承自以下基本控制器:
public class ControllerBase : ServiceStackController<CustomUserSession>
实现为:
public class ControllerBase : ServiceStackController<CustomUserSession> {}
CustomUserSession
继承自AuthUserSession
:
public class CustomUserSession : AuthUserSession
登录后,我的CustomUserSession
OnAuthenticated()
方法运行,但是当我重定向回我的控制器时,UserSession
没有填充,例如
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo)
{
base.OnAuthenticated(authService, session, tokens, authInfo);
CustomFoo = "SOMETHING CUSTOM";
// More stuff
}
public class MyController : ControllerBase
{
public ActionResult Index()
{
// After having authenticated
var isAuth = base.UserSession.IsAuthenticated; // This is always false
var myCustomFoo = base.UserSession.CustomFoo; // This is always null
}
}
谁能看到我在这里缺少的东西?