Programming Microsoft ASP.NET 4 - Dino Esposito [56]
By adding the following script, instead, you release the lock for a particular application on the machine:
With the .NET Framework 4, Microsoft made some significant changes to the CAS model for managed applications. These changes might actually cause some ASP.NET applications to fail. At risk are partial-trust ASP.NET applications that either rely on trusted code running in the global assembly cache (GAC) or require extensive modifications to machine CAS policy files. For this reason, the legacyCasModel attribute has been added to revert partial-trust ASP.NET 4 applications to the behavior of earlier versions of ASP.NET built for earlier versions of the CLR. All you do is set legacyCasModel to true if you want to include a legacy CAS-related behavior from your ASP.NET 4 application.
In ASP.NET 4, there are various ways of associating a permission set with any assemblies required by the application. As in earlier versions, you can shape up the permission set by editing the partial-trust policy file for an individual trust level (for example, web_mediumtrust.config). In addition, you can specify a permission set explicitly through the PermissionSetName attribute. In ASP.NET 4, there are three possible permission sets: FullTrust, ASP.Net, and Nothing.
The FullTrust permission set makes any code run as fully trusted. The ASP.Net permission set is typically used for partial-trust applications and is the default name assigned to the PermissionSetName attribute. Nothing is not really an alternate permission set; rather, it is simply the empty permission set. The CLR throws a security exception for any assembly associated with the empty permission set. When you change the name of the permission set, ASP.NET 4 will search the partial-trust policy file with the same name.
Note
Changing the name of the default partial trust permission set is not an action you want to take without a valid reason. The feature exists mostly for when you need a SharePoint application to define its own set of permissions distinct from those of typical ASP.NET applications. Keep in mind that with the new CAS model of the .NET Framework 4, you are no longer allowed to have multiple named permission sets to define partial-trust permissions. So you can change the name from ASP.Net to something else, but that won’t give you multiple partial trust permission sets for each application.
Finally, you can also opt for a programmatic approach to the task of choosing the permission set for an assembly. The CLR queries a HostSecurityManager object every time an assembly is loaded. One of the tasks associated with the HostSecurityManager type is returning the permission set for the assembly being loaded. In ASP.NET 4, you can gain control over this process by defining your own resolver type. A resolver type is registered through the hostSecurityPolicyResolverType attribute and consists of a type derived from the system’s HostSecurityPolicyResolver type. I’ll return to CAS for ASP.NET 4 applications in Chapter 19. You can find some good literature about this topic at http://msdn.microsoft.com/en-us/library/dd984947%28VS.100%29.aspx.
The The url attribute indicates the URL that users request from their browser. The mappedUrl attribute indicates the corresponding URL that is passed on to the application. Both URLs are application-relative. In addition to the Note The
The