Server.MapPath in Global.asax

S

Sebastiano

I want to use Server.MapPath function in Global.asax because I want to save
in an application variable the path of my database. Global.asax is in the
root directory of my web folder and database is in database/database.mdb.
Now, if I start my web site from default.aspx in the root folder all is ok,
but if start it with a page in a nested folder Global.asax can't find the
folder because Server.MapPath use the relative path of nested folder as base
for its search.

What can I do?

Many thanks

Sebastiano
 
P

Patrice

Use an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb

Patrice
 
R

Rashad Rivera

Thank you so much, I can't understand why MS did not mention the importance
of the "~" symbol in the path request. I have waisted hours trying to look
for documentation.

- Rashad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top