This paper introduces the implementation code of universal permission authentication, which is divided into import parameters, parsing XML, processing according to XML configuration, and returning results.
Code architecture diagram
First, Class introduction
1.SFWebPermission: Implement IHttpModule interface, access authentication;
2.SFConfig: Import XML Configuration class;
3.SFPermission: Parsing XML configuration for permission verification;
4.SFAccessOper: Database operation class;
5.sfpermissionsql:xml node entity class;
6.sfparameter:xml node entity class;
7.SFCommon: System variable definition class;
8.SFConst: System constants Definition class;
9.sfpermission.xml: Configuration file, which has been introduced in a format.
Second, the code structure
Figure 1
Figure 2
Code algorithm implementation is the most easily thought, the most commonly used encoding methods, the language of the more advanced usage is really not how to study, certainly is not used!
Permission validation is through the URL query to determine the primary key, so the permission entries (menu) table to have a URL column, it is recommended to add a corresponding table, as a permission entry may need to correspond to multiple URL requests.
You do not need to make any code modifications to the original project using this component.
The code is developed under the. net2.0 framework and needs to be tested in the bin directory of the Web site;
Add under the Web.config <system.web> node
If this adds an error, then add the following <system.webServer> node
<modules>
<add name= "Myhttpmodule" type= "sfpermission.sfwebpermission,sfpermission"/>
</ Modules>
The above is about ASP.net universal authorization to implement code ideas, I hope to help you learn.