A few days ago Insus.net has implemented a field in the database encryption and decryption of the "use of Encryptbypassphrase and decryptbypassphrase on a field of MS SQL Server encrypt and decrypt" HTTP/ Www.cnblogs.com/insus/p/5983645.html
This time insus.net the custom validation authorize Attribute in ASP.
Before implementation, insus.net changes to Usp_users_veryloginverify, instead, to better understand and use:
Source Code
OK, above is the database aspect.
Then you need to write the program in ASP. NET MVC:
Use cookies to store login and authentication information, and to write a cookie category:
Source Code
In fact, the above CookeBase.cs is a collection class that can store multiple objects. In the real program, you want to store what information, you can write a class like the following to operate:
Source Code
Next, we need to create a validation filter:
Source Code
This filter is SecurityAuthorizeAttribute.cs and we will apply it to the controller later.
Then you need to write the controller, no, we don't seem to have written a few objects, like model and entity:
Models write well, another entity, which is the object connected to the data:
In ASP., a demo of login verification is required, with a minimum of two controllers, one for anonymous users, which contains normal pages and some basic operations. Another controller is a page that can be accessed after it has been validated.
Another controller:
Finally, the view is created:
Source Code
There is one more:
Source Code
It's over, here's a live demo:
Http://www.cnblogs.com/insus/p/5994942.html
\asp.net MVC Custom Validation Authorize Attribute
ASP. NET MVC Custom validation authorize Attribute (contains cookie helper)