Aiub
Aiub

Reputation: 11

OLEDB security exception

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.

Upvotes: 1

Views: 4070

Answers (1)

dub stylee
dub stylee

Reputation: 3342

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.

Upvotes: 5

Related Questions