“应用程序试图执行安全策略不允许的操作”在共享虚拟主机服务器上
我在 ASP.Net 4.0 框架中创建了一个 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 服务器和测试专用服务器上都运行良好,但我们的客户购买了共享服务器并希望在共享服务器上运行。
I have created a web application in ASP.Net 4.0 framework and use LinqtoSQL for database interaction. I have build my code and upload on my shared web hosting server. Its home page working fine and all pages working fine where page content doesn't interact with database. But which pages interact database these pages gives me error :
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
How to resolve this error on our shared server??
All code works fine on our local IIS server and our testing dedicated server but our client purchased a shared server and wants to run at shared server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注意:在共享托管环境中,这些设置可能被锁定,您必须联系您的主机。
将 LINQ 与 ASP.NET 结合使用
要在中等信任度下运行的 Web 应用程序中使用 LINQ,必须在为中等信任度定义的策略文件中包含两个元素。默认情况下,web_mediumtrust.config 文件是中等信任的策略文件,这些元素安装在该文件中。
在 SecurityClasses 元素中,LINQ 需要具有以下属性的 SecurityClass 元素:
在 Name 属性设置为“ASP.Net”的 PermissionSet 元素中,LINQ 需要具有以下属性的 IPermission 元素:
NOTE: In a shared hosting environment these setting are probably locked down, you will have to contact your host.
Using LINQ with ASP.NET
To use LINQ in a Web application that is running under medium trust, you must include two elements in the policy file that is defined for Medium trust. By default, the web_mediumtrust.config file is the policy file for medium trust, and these elements are installed in the file.
Within the SecurityClasses element, LINQ requires a SecurityClass element with the following attributes:
Within the PermissionSet element that has the Name attribute set to "ASP.Net", LINQ requires an IPermission element that has the following attributes: