从ActionFilterAttribute进入会话 [英] Getting to Session from ActionFilterAttribute

查看:130
本文介绍了从ActionFilterAttribute进入会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在MVC4上,我正在实现从"ActionFilterAttribute"派生的属性,但是我需要获取存储在用户会话中的数据以用于记录目的

Hi
On MVC4, I''m implementing an attribute derived from "ActionFilterAttribute", but I need to get to data that''s stored inside the user session for logging purposes

public class MvcTraceAttribute: ActionFilterAttribute
{
    public override void OnActionExecuting(HttpActionContext actionContext)
    {
        // How do I get to HttpContext.Session["..."] from here?
    }
}



有什么想法吗?

谢谢
Eugene



Any ideas?

Thanks
Eugene

推荐答案

使用System.Web.HttpContext.Current.Session
您项目中任何可以访问当前会话的地方
use System.Web.HttpContext.Current.Session
anywhere in ur project to access current session


这篇关于从ActionFilterAttribute进入会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆