1

I published a web app to a server and I would like to access a database file (.mdb) that is also stored on the server in a different location outside of mine. How can I do this in the web.config file of my Asp.Net app?

<add name="MyOleDbConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= **{?}** \inventory.mdb"/>
1
  • Can you define "outside of mine"? Do you mean that it's outside the root of the web application? Commented Sep 30, 2011 at 17:08

1 Answer 1

1

I don't believe you can do it from code, using anything like Server.MapPath() - and for good reason. This would allow developers to write apps that take over host operating systems on cloud servers. You're restricted from determining the path of files/folders outside of the control of IIS to prevent directory traversal attacks.

You'll need to ask a SysAdmin, or someone who has access what the path is on that machine. Once you have the full path, you can set the full path in the .config

c:\path\inventory.mdb

instead of

\inventory.mdb

You will also need to make sure that the SysAdmin grants you permissions to access the .mdb.

Sign up to request clarification or add additional context in comments.

2 Comments

My project is currently in a virtual directory and the .mdb file is in a directory outside of my virtual directory.
Thanks, it worked. I called the SysAdmin and they gave me the complete path ouside the virtual folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.