473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Server.MapPath in Global.asax

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
Nov 18 '05 #1
3 4775
Use an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb

Patrice

"Sebastiano" <in**@sebastianogazzola.it> a écrit dans le message de
news:Ot**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2
try to use Request.PhysicalApplicationPath to combine path

--
Thanks.

Lostinet (MS ASP.NET MVP)
lo*********@hotmail.com
---------------------------
Need MessageBox,ComboBox,DatePicker,PasswordBox,TreeVie w,ASP.Net RPC ?
http://www.lostinet.com/
"Sebastiano" <in**@sebastianogazzola.it> дÈëÏûÏ¢
news:Ot**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #3
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" <no****@nowhere.com> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl...
Use an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb

Patrice

"Sebastiano" <in**@sebastianogazzola.it> a écrit dans le message de
news:Ot**************@TK2MSFTNGP10.phx.gbl...
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


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a...
3
by: Sebastiano | last post by:
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...
4
by: Andy Fish | last post by:
Hello, I've found that if I try to do a Server.MapPath() in the Session_End event, it fails with an exception. is this right? any simple way to work round it? is there any documentation...
2
by: Oberon | last post by:
Why does this not work as it should? I expect index.aspx to show:. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ChatSimple\db\chatusers.mdb Instead, I get: ...
2
by: rgparkins | last post by:
Hi Guys Maybe a simple and easy solution to this, but I keep getting exception object not set to instance etc etc. I have a Timer that is initiated in Application_Start in Global.asax. This...
1
by: xeroxero | last post by:
When a user hits a web page in ASP.NET 2.0, I can use HttpContext.Current.Server.MapPath("~/mydir") to find the real filesystem location of a file. But in an event triggered in my global.asax,...
7
by: teo | last post by:
I need to use the 'Server.MapPath' function in the 'Session_End' event of the Global.asax file (to reach a folder and the clean some temporary files up), but it doesn't work: Sub...
0
by: Michael | last post by:
Hi I have a problem related to global.asax and the Server.Mappath-Method. I collect all unhandled errors in the Application_Error in Global.asax. According to the type of error I...
4
by: glbdev | last post by:
Hi. I am having an problem connecting to a remote SQL Server. Other applications (using access) are connection to it but I cannot get it to work through ASP.Net. Here is my connection string:...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.