473,473 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4779
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.