该应用程序尝试执行安全策略不允许的操作“在具有MS SQL的共享虚拟主机服务器ASP.NET 4.0上

时间:2013-05-14 09:32:24

标签: asp.net sql-server hosting web-hosting shared-hosting

我在ASP.Net 4.0框架中创建了一个Web应用程序,并使用MS-SQL进行数据库交互。我已经构建了我的代码并上传到我的共享Web托管服务器上。它的主页工作正常,所有页面工作正常,页面内容不与数据库交互。但是哪些页面与数据库交互,这些页面给出了错误:

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 failed.


Stack Trace: 

[SecurityException: Request failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +165
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +272
System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandleInternal rmh) +59
System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandleInternal rmh) +54
System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +33
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext) +154
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant) +54
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(PermissionType permission, PermissionSet targetGrant) +29
System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Type owner, StackCrawlMark& stackMark, Boolean skipVisibility) +10540369
System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility) +48
Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes, Type owner) +86
Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor(Type type) +68
Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator(Type createdType) +37
Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract) +257
Newtonsoft.Json.Serialization.DefaultContractResolver.CreateArrayContract(Type objectType) +40
Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType) +243
Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type) +105
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) +80
Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) +47
Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) +98
Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonConverter[] converters) +71
Newtonsoft.Json.JsonConvert.DeserializeXmlNode(String value, String deserializeRootElementName) +80
Ext.Net.XControl.get_SubmitConfig() +80
Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument) +560
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9643314
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
System.Web.UI.Page.ProcessRequest() +72
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +58
ASP.cms_files_images_aspx.ProcessRequest(HttpContext context) +37
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

如何在共享服务器上解决此错误?

所有代码在我们的本地IIS服务器和测试专用服务器上运行正常,但我们的客户购买了共享服务器,并希望在共享服务器上运行。

此问题类似于"The application attempted to perform an operation not allowed by the security policy" on shared webhosting server

上发布的帖子

但其解决方案适用于LINQ with ASP.NET。我需要使用ASP.NET的MSSQL解决方案

2 个答案:

答案 0 :(得分:0)

嗯......如果我看到上面的错误消息,您似乎需要完全许可。您的托管服务提供商是否支持完全信任?

答案 1 :(得分:0)

您可以尝试在web.config文件中添加以下代码:

<system.web>
<trust level="Full" originUrl=""/>
</system.web>