共享虚拟主机服务器上的"The application attempted to perform an operation not allowed by the security policy"



我在ASP中创建了一个web应用程序。并使用LinqtoSQL进行数据库交互。我已经建立了我的代码,并在我的共享网络托管服务器上上传。它的主页工作正常,所有页面工作正常,页面内容不与数据库交互。但是哪些页面与数据库交互,这些页面给我错误:

    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.]
   DataContextFactory.GetWebRequestScopedDataContextInternal(Type type, String key, String connectionString) in DataContextFactory.cs:81
   DataContextFactory.GetWebRequestScopedDataContext() in DataContextFactory.cs:42
   members_buyer_mypostedjobs..ctor() in mypostedjobs.aspx.cs:19
   ASP.members_buyer_mypostedjobs_aspx..ctor() in App_Web_soaq30qq.4.cs:0
   __ASP.FastObjectFactory_app_web_soaq30qq.Create_ASP_members_buyer_mypostedjobs_aspx() in App_Web_soaq30qq.9.cs:0
   System.Web.Compilation.BuildResultCompiledType.CreateInstance() +32
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +109
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
   System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path) +37
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +334
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

如何解决这个错误在我们的共享服务器?

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

注意:在共享主机环境中,这些设置可能被锁定,您必须联系您的主机。

在ASP中使用LINQ净

要在中等信任下运行的Web应用程序中使用LINQ,必须在为中等信任定义的策略文件中包含两个元素。缺省情况下,web_mediumtrust。配置文件是中等信任的策略文件,这些元素安装在文件中。

在SecurityClasses元素中,LINQ需要SecurityClass元素具有以下属性:

<SecurityClass 
  Name="ReflectionPermission" 
  Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

在PermissionSet元素中,该元素的Name属性设置为"ASP. net"。. Net", LINQ需要一个IPermission元素,该元素具有以下属性:

<IPermission
  class="ReflectionPermission"
  version="1"
  Flags="RestrictedMemberAccess"
/>

相关内容

最新更新