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