我在 ASP.Net 4.0 框架中创建了一个 Web 应用程序,并使用 MS-SQL 进行数据库交互。我已经构建了我的代码并上传到我的共享网络托管服务器上。它的主页工作正常,并且页面内容不与数据库交互的所有页面工作正常。但是哪些页面与数据库交互这些页面给了我错误:
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 服务器和我们的测试专用服务器上都可以正常工作,但我们的客户购买了共享服务器并希望在共享服务器上运行。
此问题类似于发布在共享虚拟主机服务器上的“应用程序尝试执行安全策略不允许的操作”上的线程
但它的解决方案是针对带有 ASP.NET 的 LINQ。我需要用 ASP.NET 解决 MSSQL