这是我的第一个问题,所以我为我的英语道歉:)
我们正在使用Jasig CAS SSO提供的身份验证来构建MVC 4应用程序。
它的工作非常好,但我需要在用户身份验证之后执行自定义操作。
步骤应类似于:
操作5.成功登录后只运行一次!下一个请求跳过这个步骤。
我读过有关表单身份验证的CAS和MSDN文档,但我无法提供任何信息。
我发现我可以扩展AuthorizeAttribute并覆盖AuthorizeCore方法,但是它会运行每个请求。
谢谢你的帮助
发布于 2014-02-05 09:21:20
我自己找到答案了。也许有更好的决心,但这个决定使我想要的。
要在Jasig CAS登录后进行一些自定义操作,您需要实现
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
在Global.asax中
样本代码:
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
//must check if user is authenticated (this method can be called before authentication)
if (Context.User.Identity.IsAuthenticated && Context.Session != null && Context.Session["IsLogged"] == null)
{
Context.Session.Add("YourKey", YourData);
Context.Session.Add("IsLogged", true);
}
}如果需要,可以在标准窗体身份验证中使用相同的方法。
https://stackoverflow.com/questions/19830693
复制相似问题