Code access security, as the name suggests, is used to restrict code. It can limit whether the code can be executed, and in turn, limit what action the ASP.net program can perform. For example, CAS restrictions you do not allow the use of FileIOPermission, then the ASP.net program can not be IO operation. Again, if you limit your use of sqlclientpermission,asp. NET program will not be able to operate SQL Server.
The CAS default defines 5 different level, which are full,high,medium,low and minimal. Permissions are getting lower from full to minimal. Basically, anything can be done at full level, and the minimal level can only perform the most basic mangered code. In our ASP.net program, the trust level is configured in the web.config in the root directory, such as: <trust level= "full"/> If you do not configure it, the default is full level. Today, a host admin role tells you how to protect the server through CAs. There are probably several steps:
1 Identify what action the ASP.net program on the server needs to do.
2 Select one of the most appropriate levels from the predefined 5 levels.
3 If there is no suitable, define a level yourself.
4 The definition level is not allowed to be overwritten.
5) test results.
Step one: Identify what action the ASP.net program on the server needs to do. This is based on host admin to decide, in this respect I do not have much experience, here but more discussion. P.S. If you want to know what permissions your asp.net program needs, you can view it with a tool from the. NET framework. This tool is called Permissions Calculator Tool, and we can call it through the. NET Framework Command window:
Input: percalc-show D:\MyProjects\Job\bin\Job.dll carriage return