File permission in asp.net 2.0

I have been using hand coded asp.net 1.1 successfully for quite some time.

But recently, I uploaded a VS 2005 developed web form (grid showing an access db) to my asp.net 2.0 enabled site. This works fine on my local PC. But on the web site, it gives the following type of error:

Error: System.Web.HttpException: Access to path 'test.mdb' was denied. The location does not exist or is not accessible because of security settings.
at System.Web.HttpRuntime.CheckFilePermission(String path, Boolean writePermissions)...

I already submitted a ticket to fix file/folder permissions and the support replied that they did that. But the problem has not gone. While I wait for more on this from support, does anyone have any clues on this? Is it strictly file permission or do you have to do something else to be able to run VS 2005 developed apps on the shared hosting platform?
 
What are you using to connect to your database? OLE DB, ODBC?
I don't think either of those would give that specific error message..

I think the medium trust settings on .NET allow only direct file access to files that are inside the application directory. I never really understood why this was done.. but could that be the problem?
 
The VS 2005 project is using an asp:AccessDataSource that points the DataFile attribute to that file in the other folder.

>>I think the medium trust settings on .NET allow only direct file access to files that are inside the application directory.<<

I have another web site in 2.0 that is able to use an mdb in another folder but that is using a connection string when creating an OleDbConnection object. That works fine.
OleDbConnection oConnection = new OleDbConnection "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + ConfigurationSettings.AppSettings["database"]);

What is different in the DataFile method vs the above? How to change it to use a connection? I don't know .net that well.

I will try hand coding a connection in a test program to see if that works.

Thanks,
Sanjay
 
Yes, that worked. I didn't know about this new App_data stuff in .net 2.0. I changed the datafile to "~/App_data/test.mdb" and it worked.

BTW, is there a similar folder and relative path possible for putting DLLs to load with DllImport? Currently, I have to give an absolute path to DllImport.

Thanks,
Sanjay
 
I think the difference is that the control does it's own checking if the file exists and is accessible before ever creating the database connection, which is why it only functions inside the application directory with these trust settings.

Uhm, what are you using the DllImport attribute for? That means you're calling unmanaged code. That's not going to work in anything but a full trust environment. The only way to get that at JodoHost would be getting a Windows VPS account or a dedicated server.
 
Thanks. I understand now.

About Windows VPS, I am confused. I am not sure if it would require more work on my part. In shared hosting, I can count on many things like backup, monitoring and other software. In VPS, do I have to take care of these things and manage IIS myself, buy software licenses etc? I guess, this is for JodoHost people to reply. In other words, what do I have to do extra in VPS as compared to shared hosting.
 
Back
Top