Server.MapPath in Global.asax

  • Thread starter Thread starter Sebastiano
  • Start date Start date
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
 
Use an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb

Patrice
 
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
 
Back
Top