ASP.NET: Access Session variable in global.asax

前端 未结 3 723
长发绾君心
长发绾君心 2021-01-18 01:34

I have an ASP.NET application and in the Global.asax \' Application Error Event, I am calling a method to trace/log the error. I want to use the session variable content her

3条回答
  •  鱼传尺愫
    2021-01-18 02:33

    You may try this:

    HttpContext context = ((HttpApplication)sender).Context;
    

    then you must use is like this:

    context.Request.QueryString.ToString()
    context.Session["key"] = "fasfaasf";
    

    but if the exception was thrown before the Session object is loaded, it will be null

提交回复
热议问题