OLEDB security exception

倖福魔咒の 提交于 2021-02-05 08:20:51

问题


I'm using ASP.NET 4.0 with C# for an web application. There was a part to import data from excel file. I've used Microsoft.Jet.OLEDB.4.0 to do that. The process is-

  1. Upload the file to App_Data directory
  2. Retrieve data to a list
  3. Delete uploaded file from App_Data

It works fine from my localhost. But when I hosted the site at Godaddy, it fails to perform data extraction.

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

I know for sure that the App_Data directory has the read and write permissions and I can see that it uploads the file successfully to App_Data folder.


回答1:


In the <System.Web> section of your web.config file, add the following:

<trust level="Full" />

That should elevate your trust level, and you should be able to function normally after that.



来源:https://stackoverflow.com/questions/24942021/oledb-security-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!