问题
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-
- Upload the file to App_Data directory
- Retrieve data to a list
- 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: 0Stack 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