Creating security in ASP.NET web site Author: Unknown Hits: 4641 Joined: 2003-5-30 14:04:27 before using ASP, PHP, when writing website code JSP, site security is always a headache Things, although we wrote the 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 verification, our processing method is to click any page when the user does not verify, and the specific code is as follows: authorization> But this will generate a problem, That is if I have some information that can be freely accessed by any user, such as the 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> system.Web> location> Solved the above two questions, 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: <% @ page language = "c #" codebehind = "login.aspx.cs" autoeventwireup = "false" inherits = "secure.login"%>
secure site title> HEAD>