ASP.NET Security Exception

2019-09-05 17:07发布

问题:

I moved an ASP.NET application from a XP to a new server and now I have this exception:

'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral,

On this line code:

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("it-IT");

My server is so configurated: Windows XP 2003 Sever SharePoint MS Visual Studio 2008 Team System Workgroup Server

I tried to change security setting, machine.config. Someone can help me explain me where and how to change what?

Thanks a lot.

回答1:

SharePoint doesn't consider all assemblies in the .NET Framework as safe you just need to add a couple of lines to your web.config file in your application.

Do it in the Sharepoint SafeControls section:

<SafeControl Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="System.Security" TypeName="*" Safe="True" AllowRemoteDesigner="True" />
<SafeControl Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="System.Security.Permissions" TypeName="*" Safe="True" AllowRemoteDesigner="True" />