Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Server.MapPath in Global.asax

Reply
Thread Tools

Server.MapPath in Global.asax

 
 
Sebastiano
Guest
Posts: n/a
 
      04-16-2004
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


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      04-16-2004
Use an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb

Patrice

"Sebastiano" <(E-Mail Removed)> a crit dans le message de
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Lostinet
Guest
Posts: n/a
 
      04-16-2004
try to use Request.PhysicalApplicationPath to combine path

--
Thanks.

Lostinet (MS ASP.NET MVP)
http://www.velocityreviews.com/forums/(E-Mail Removed)
---------------------------
Need MessageBox,ComboBox,DatePicker,PasswordBox,TreeVie w,ASP.Net RPC ?
http://www.lostinet.com/
"Sebastiano" <(E-Mail Removed)> дϢ
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Rashad Rivera
Guest
Posts: n/a
 
      04-16-2004
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

"Patrice" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Use an absolute path for the Server.MapPath argument such as
> ~/database/database.mdb instead of just database/database.mdb
>
> Patrice
>
> "Sebastiano" <(E-Mail Removed)> a crit dans le message de
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments