Implementation Code of ASP. NET general permission verification,
This article introduces the implementation code of general permission verification, which includes importing parameters, parsing XML, processing according to XML configuration, and returning results.
Code Architecture
I. Class Introduction
1. SFWebPermission: implements the IHttpModule interface and permission verification portal;
2. SFConfig: Import XML configuration class;
3. SFPermission: Parse 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 constant definition class;
9. SFPermission. xml: configuration file. The format has been described in the previous article.
Ii. code structure
Figure 1
Figure 2
The Algorithm Implementation of the code is the easiest to think of and the most commonly used encoding method. The advanced usage in the language has never been studied. It is certainly not used!
Permission verification is based on the primary key obtained through URL query. Therefore, the permission Project (menu) Table must have a URL column. We recommend that you add a corresponding table, assume that a permission item may need to correspond to multiple URL requests.
Using this component does not require any code modifications to the original project.
The code is developed under the. net2.0 framework and needs to be tested under the bin directory of the website;
Add
If an error occurs, add the following content under the <system. webServer> node.
<modules><add name="myHttpModule" type="SFPermission.SFWebPermission,SFPermission"/></modules>
The above is the implementation code of ASP. NET general permission verification. I hope it will be helpful for you to learn.
Articles you may be interested in:
- Asp.net FCKEditor 2.6.3 you are not authorized to upload files. solution:
- Asp.net Forms authentication and role-based access
- Instance description simple role permission control in asp.net
- A permission Scheme Based on Asp. Net MVC
- Simple and efficient permission design example implemented by asp.net + sqlserver
- Asp.net BasePage class + Session General user logon permission Control
- Set IIS permissions for ASP. NET Word operations
- Asp.net Mvc authentication, exception handling, permission verification (interceptor) implementation code
- ASP. NET.4.5.1 + MVC5.0 set system roles and permissions (1)