Upgrading to ASP.Net 2? Why Your Website Might Stop Working When You Do

Asp.Net version 2 was just recently released by Microsoft and contains a feature rich set of classes that can do just about anything imaginable. However if your thinking about hosting your asp.net 2 site on a shared hosting environment there are a few considerations you should know about before you take the plunge. If you have already upgraded you may be wondering why your site that was working fine in version 1.1 but now has problems working in Asp.Net version 2.

Code Access Security

If you receive one of those generic yellow error messages that say something like the following:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

The Reason? - Code Access Security!

As it turns out many shared hosting companies are setting the Security Trust level in the asp.net version 2.0 machine.config files to the default