Using dscf.client.web.class;using dscf.client.web.dscfservice;using dscf.client.web.handler;using System;using System.collections.generic;using system.linq;using system.servicemodel;using system.web;using System.web.sessionstate;namespace dscf.client.web.httpmodules{ public class Authentication:ihttpmodule , irequiressessionstate { public void Dispose () {} Pub LIC void Init (HttpApplication context) { //start at ASP. This event is raised before the handler for the line HTTP request context. PreRequestHandlerExecute + = context_prerequesthandlerexecute; } private void Context_prerequesthandlerexecute (object sender, EventArgs e) { &NBSP ; HttpApplication application = (HttpApplication) sender; Uri u Ri = Application. context.request.url; String loginurl = "/view/login.aspx"; &N Bsp IF (! Getcommonurl (). Contains (URI. Absolutepath.tolower ()) &&!uri. Absolutepath.startswith ("/combres.axd/") && (URI. Absolutepath.contains (". aspx") | | Uri. Absolutepath.contains (". ashx"))) { &NBSP ; Operaterinfo oper = Application. context.session["Operator"] as operaterinfo; if (oper = = null)   ; { AP Plication. Response.Redirect (Loginurl, True); } &NB Sp list<pagerights> rights = Application. Session["Rights"] as list<pagerights>; if (rights = = NULL | | Rights. Count <= 0) { &N Bsp if (oper. Roles = = NULL | | Oper. Roles.length <= 0) { &N Bsp gotoforbiddenpage (application. Context); } else { &NBSP ; rights = new list<pagerights> (); forEach (var role in Oper. Roles) { &NB Sp rights. AddRange (role. pagerights); } &NBS P application. Session["rights"] = rights; } &NB Sp } int type; Int. TryParse (Application. request["Type"], out type); var right = rights. FirstOrDefault (M = M.pageurl.trim (). ToLower () = = URI. Absolutepath.tolower () && m.editright = = type); IF(right = null) { & nbsp if (URI. Absolutepath.endswith (". ashx")) { application. Response.Write (False, "you do not have permission to do this, please contact your administrator for higher privileges!"). ")); application. Response.End (); } & nbsp else { &NBSP ; gotoforbiddenpage (application). Context); } }&NBSP; } } private void Gotoforbiddenpag E (HttpContext context) { context. Response.Redirect ("/error/forbidden.html", true); } Private list& Lt;string> Getcommonurl () { list<string> List = new List<string> (); List. ADD ("/view/login.aspx"). ToLower ()); list. ADD ("/view/finainvestlist.aspx"). ToLower ()); list. ADD ("/handler/login.ashx"). ToLower ()); list. ADD ("/view/investlogin.aspx"). ToLower ()); list. ADD ("/handler/investloginhandler.ashx"). ToLower ()); list. ADD ("/handler/finainVesthandler.ashx ". ToLower ()); list. ADD ("/handler/kefile_manager_json.ashx"). ToLower ()); list. ADD ("/handler/keupload_json.ashx"). ToLower ()); list. ADD ("/handler/codehandler.ashx"). ToLower ()); list. ADD ("/handler/isuserinfoexisthandler.ashx"). ToLower ()); list. ADD ("/handler/jumploginhandler.ashx"). ToLower ()); list. ADD ("/"); return list; } }}
Before ASP. NET begins executing a handler for an HTTP request