1
我有.NET MVC5应用程序与ServiceStack。在一个AuthenticationFilter中,我想检查一个特定的属性是否在会话中。C#.NET MVC服务栈如何从身份验证过滤器访问自定义用户会话
在AuthController:
var customerSession = SessionAs<CustomerUserSession>();
customerSession.property = "some value";
在筛选:
public class MyAuthFilter : ActionFilterAttribute, IAuthenticationFilter
{
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
{
// I want to access that property here
}
}
我的自定义会话从服务栈实现AuthUserSession。
在此先感谢!
SessionAs是类ServiceStackController的保护方法,所以我不认为它可以用于你的方式”已经描述过。 – Nikola
@尼古拉确定你应该可以使用'ServiceStackProvider.SessionAs();' –
mythz