zoukankan      html  css  js  c++  java
  • 系统统一验证(IHttpHandlerFactory)<转>

    代码
    public class ValidateHttpHandlerFactory : IHttpHandlerFactory, IReadOnlySessionState
    {
        #region IHttpHandlerFactory 成员

        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            PageHandlerFactory factory 
    = (PageHandlerFactory)Activator.CreateInstance(typeof(PageHandlerFactory), true);
            IHttpHandler handler 
    = factory.GetHandler(context, requestType, url, pathTranslated);
            Page page 
    = handler as Page;
            
    if (page != null)
            {
                page.Init 
    += new EventHandler(page_Init);
            }
            
    return handler;
        }

        public 
    void ReleaseHandler(IHttpHandler handler)
        {

        }

        #endregion

        
    void page_Init(object sender, EventArgs e)
        {
             
    //这里来验证访问用户的合法性
            //Session
           //需要排除登录页面
        }

    }
    由于系统中是使用Session保存用户信息,所以在这里要访问Session需要继承IReadOnlySessionState接口。

    如果还要写Session就需要继承IRequiresSessionState接口。

    然后在web.config里面配置。

    <httpHandlers>
        
    <add path="*.aspx" verb="*" type="Hxj.Web.HttpHandlerFactory.ValidateHttpHandlerFactory,Hxj.Web.HttpHandlerFactory"/>
    </httpHandlers>
    这样就可以接管aspx页面,并且注册了Init 事件,来验证用户。

    原文地址:http://www.cnblogs.com/huxj/archive/2010/05/22/1741799.html
  • 相关阅读:
    Geoserver通过ajax跨域访问服务数据的方法(含用户名密码认证的配置方式)
    123
    递归____蛮好的例子 蓝桥
    博弈_____威佐夫博奕
    123123
    sort
    int ,long , long long类型的范围
    数学推导_循环小数转分数
    下一步:结构体 背包 库函数
    回溯____蓝桥 棋盘
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1777790.html
Copyright © 2011-2022 走看看