【问题标题】:Using Handler class使用处理程序类
【发布时间】:2011-10-13 07:21:37
【问题描述】:

我在处理程序类中编写了以下内容来检查会话 饱和。

 public void ProcessRequest(HttpContext context)
        {
            if (context.Session["UserID"] == null || context.Session["ClientCode"] == null || context.Session["UserType"] == null)
            {
                context.Response.Redirect("~/LogIn.aspx");
            }
        }

现在我需要让它影响我的应用程序中的每个 .aspx 页面,我该怎么做?

【问题讨论】:

  • 你可以把这段代码放在 Global.asax 文件中

标签: asp.net session httphandler


【解决方案1】:

您要么需要IHttpModule,要么在Global.asax 的某处订阅Application.BeginRequest 事件。前者更简洁,但需要更改Web.config,后者可能不太干净,但代码更少,不需要更改配置。

【讨论】:

    猜你喜欢
    • 2011-12-31
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-25
    • 2021-09-13
    • 2023-02-21
    • 1970-01-01
    相关资源
    最近更新 更多