c# - OLEDB 安全异常

标签 c# asp.net sql-server oledb

我将 ASP.NET 4.0 与 C# 一起用于 Web 应用程序。有一部分是从 excel 文件导入数据。我已经使用 Microsoft.Jet.OLEDB.4.0 来做到这一点。 过程是——

  1. 上传文件到App_Data目录
  2. 将数据检索到列表
  3. 从 App_Data 中删除上传的文件

它在我的本地主机上运行良好。但是当我在 Godaddy 托管网站时,它无法执行数据提取。

Server Error in '/' Application.

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 for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error: [No relevant source lines]

Source File: App_Web_importquestion.aspx.2edad644.wy5h2tcw.0.cs
Line: 0

Stack Trace:

[and so on.....]

我确定App_Data目录有读写权限,我可以看到它成功上传了文件到App_Data文件夹。

最佳答案

<System.Web>你的部分web.config文件,添加以下内容:

<trust level="Full" />

这应该会提升您的信任度,之后您应该能够正常工作。

关于c# - OLEDB 安全异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24942021/

相关文章:

asp.net - 多个域的集成 Windows 身份验证

c# - 尝试使用 .netstandard 2 程序集时出现 Web Api 2 运行时错误

sql - HAVING 和 WHERE 子句的区别

mysql - 如何从以默认关键字作为表名的表中选择数据

c# - 数据表的Linq操作

c# - OSX 上的 Visual Studio Code 如何导入 sln/csproj 并运行?

c# - Azure 预编译函数的 URL 格式应该是什么?

c# - 评估 LambdaExpression?

asp.net - 将 jQuery 用于 AJAX 和 ASP.NET Webforms

sql-server - SQL 服务器 : tools to show relations