In the past, the site security is always a headache, although we have written user login, registration, verification page, but the effect is always not ideal. Sometimes we have to use a large number of session variables to store relevant information, we will be in place. In the .NET environment, this problem is very easy. The key is to fully understand the Web.config file. First, describe the web.config file.
XML Version = "1.0" encoding = "UTF-8"?> tag to each error to be processed. -> Authorized this section to set the application Authorization strategy. The application resource can be allowed or rejected to access the user or role. Wildcard: "*" means anyone, "?" Indicates anonymous (unauthorized) user. -> - (comma-separated user list] "Roles =" [comma-separated role List] "/> -> authorization>
->
configuration> Ok, I believe that after reading the above introduction, I must know very well for web.config files. Let it be. Below we will cut the subject. In order to prevent the user from accessing the site without verifying, our processing method is when the user does not pass the validation, click any page to be jumped directly to the login.aspx page, the specific code is as follows:
authorization> But this will generate a problem, that is, if some of my site has some information, any user can access, such as site profile, use instructions, etc. If you don't let users feel troublesome, huh, huh, not anxious, naturally have a corresponding solution in ASP.NET. The following code can implement anonymous user access Test.aspx page:
authorization> location>
Solved the two questions above, I believe that everyone must have it. The Login.aspx page is started below. Use C # and SQL Server2000 to create a WebForm page, join the appropriate controls. The specific code is as follows: