473,686 Members | 3,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Server.MapPath problem?

Why does this not work as it should?

I expect index.aspx to show:.

Provider=Micros oft.Jet.OLEDB.4 .0;Data
Source=c:\inetp ub\wwwroot\Chat Simple\db\chatu sers.mdb

Instead, I get:

Provider=Micros oft.Jet.OLEDB.4 .0;Data
Source=c:\inetp ub\wwwroot\Chat Simple\chatuser s.mdb\chatusers .mdb

It is running on Windows XP Pro, SP1, IE6.
1) IIS has been set with:

ChatSimple, Properties, HTTP Headers, Enable Content Expiration
(ticked), Content Should "Expire Immediately"

Then restarted from the cmd line with:
net stop W3SVC
net start W3SVC
2) Here is the Global.asax.vb

+ + + + + + +

Imports System.Web
Imports System.Web.Sess ionState

Public Class Global
Inherits System.Web.Http Application

Public Sub New()
MyBase.New()
InitializeCompo nent()
End Sub

Private components As System.Componen tModel.IContain er
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r()
End Sub

Sub Application_Sta rt(ByVal sender As Object, ByVal e As
EventArgs)
Application("Ch atConnString") =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "/db/ChatUsers.mdb")
End Sub

End Class

+ + + + + + +

3) Here is the index.aspx page:

+ + + + + + +

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html;
charset=windows-1252">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>Chat Simple</title>
</HEAD>
<BODY>
<%Response.Writ e(Application(" ChatConnString" ))
Response.End %>
</BODY></HTML>

+ + + + + + +

Nov 19 '05 #1
2 3516
1) I had my browser cache off.

Tools, Internet Options, General, Settings, Check for newer
versions of stored pages - every visit to the page.

2) I switched off IIS caching (see below)

3) I set my HTTP headers (see below)

4) Finally I added even more lines to index.aspx (see new
version below).

5) Restarted IIS, just for good measure.

Nothing worked. Still the same obsolete application variable
shown. Eventually I renamed the application variable to
Application("db ConnString")) - effectively killing the old one.
That worked, but before that, altering the value in the
Application variable did nothing. eg.

Application("Ch atConnString") =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "\")

still gave the wrong value.

Now (after renaming the Application variable) the Index.aspx
page is showing nothing, which is an improvement on it showing
the wrong value but ... why didn't the value change when I
re-coded it in Global.aspx.vb.

I'm totally baffled.

+ + + + + + +
New Index.aspx with more code to kill cached pages.
+ + + + + + +
<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html;
charset=windows-1252">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>Chat Simple</title>
</HEAD>
<BODY>
<% Response.CacheC ontrol = "no-cache" %>
<% Response.Expire s = -1 %>

<%Response.Writ e(Application(" dbConnString"))
Response.End %>
</BODY></HTML>
+ + + + + + +

The only thing that actually worked

On Wed, 11 May 2005 11:40:01 GMT, Oberon <ob****@solstic e.com>
wrote:
Why does this not work as it should?

I expect index.aspx to show:.

Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=c:\inet pub\wwwroot\Cha tSimple\db\chat users.mdb

Instead, I get:

Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=c:\inet pub\wwwroot\Cha tSimple\chatuse rs.mdb\chatuser s.mdb

It is running on Windows XP Pro, SP1, IE6.
1) IIS has been set with:

ChatSimple, Properties, HTTP Headers, Enable Content Expiration
(ticked), Content Should "Expire Immediately"

Then restarted from the cmd line with:
net stop W3SVC
net start W3SVC
2) Here is the Global.asax.vb

+ + + + + + +

Imports System.Web
Imports System.Web.Sess ionState

Public Class Global
Inherits System.Web.Http Application

Public Sub New()
MyBase.New()
InitializeCompo nent()
End Sub

Private components As System.Componen tModel.IContain er
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeComp onent()
components = New System.Componen tModel.Containe r()
End Sub

Sub Application_Sta rt(ByVal sender As Object, ByVal e As
EventArgs)
Application("Ch atConnString") =
"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=" &
Server.MapPath ("/db/ChatUsers.mdb")
End Sub

End Class

+ + + + + + +

3) Here is the index.aspx page:

+ + + + + + +

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html;
charset=window s-1252">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>Chat Simple</title>
</HEAD>
<BODY>
<%Response.Wri te(Application( "ChatConnString "))
Response.End %>
</BODY></HTML>

+ + + + + + +


Nov 19 '05 #2
That code works fine here. Did you do an iisreset after a previous test?

BTW, you might find it easier and more secure to put that string in the
web.config.

http://msdn.microsoft.com/library/de...SecNetHT08.asp

Ken

"Oberon" <ob****@solstic e.com> wrote in message
news:68******** *************** *********@4ax.c om...
Why does this not work as it should?

I expect index.aspx to show:.

Provider=Micros oft.Jet.OLEDB.4 .0;Data
Source=c:\inetp ub\wwwroot\Chat Simple\db\chatu sers.mdb

Instead, I get:

Provider=Micros oft.Jet.OLEDB.4 .0;Data
Source=c:\inetp ub\wwwroot\Chat Simple\chatuser s.mdb\chatusers .mdb

It is running on Windows XP Pro, SP1, IE6.
1) IIS has been set with:

ChatSimple, Properties, HTTP Headers, Enable Content Expiration
(ticked), Content Should "Expire Immediately"

Then restarted from the cmd line with:
net stop W3SVC
net start W3SVC
2) Here is the Global.asax.vb

+ + + + + + +

Imports System.Web
Imports System.Web.Sess ionState

Public Class Global
Inherits System.Web.Http Application

Public Sub New()
MyBase.New()
InitializeCompo nent()
End Sub

Private components As System.Componen tModel.IContain er
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r()
End Sub

Sub Application_Sta rt(ByVal sender As Object, ByVal e As
EventArgs)
Application("Ch atConnString") =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "/db/ChatUsers.mdb")
End Sub

End Class

+ + + + + + +

3) Here is the index.aspx page:

+ + + + + + +

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html;
charset=windows-1252">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>Chat Simple</title>
</HEAD>
<BODY>
<%Response.Writ e(Application(" ChatConnString" ))
Response.End %>
</BODY></HTML>

+ + + + + + +

Nov 19 '05 #3

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

Similar topics

13
14317
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 path within c:\Inetpub\wwwroot rather than the real path. Can anyone please tell me why this isn't working? Regards, John
7
14375
by: A P | last post by:
I receive an error like this: Server.MapPath() error 'ASP 0172 : 80004005' Invalid Path /conn.asp, line 2 The Path parameter for the MapPath method must be a virtual path. A physical path was used.
4
1927
by: Laphan | last post by:
Hi All Sorry to be irate, but the whole concept of Server.MapPaths really has me in a tiswas!! In order to confirm once and for all, could you please advise me on the following: 1) There is no difference in putting '/' or '\' in the Server.MapPath param, eg Server.MapPath("/fred/test.asp") or Server.MapPath("\fred\test.asp") -
7
2358
by: laura | last post by:
I'm trying to understand fully Server.MapPath. I am writing an intranet for a small company and want to be able to put some files accessible to all, hyperlinked from the intranet and therefore, outside of the website area - the idea being that I want staff to be able to copy files into folders that can be accessed by hyperlinks on the intranet pages. I've had a problem separating them from the intranet HTML and ASP pages, which is...
2
4606
by: GhislainTanguay | last post by:
This is my XML file and below you will find my code to remove it... I was thinking that it's a simple task but this code doesn't work. Anybody have a better solution? <Advertisements>
2
3795
by: Tee | last post by:
Hi, I am currently using Server.MapPath in my aspx files, but because of I am using it more than once, I would like to move these code away from aspx and make it as a public function inside Module, but I am having problem with it. As "Server.MapPath" is not allow in other .vb file ... can anyone help with this ? or if we really can't make it, is there any other way could do it ? Thanks,
6
3862
by: Nathan Sokalski | last post by:
When using the Server.MapPath() method, the results being returned are given as locations on my hard drive. I would like to be returned a result that is a URL, in my case something like the following: http://localhost/WebApplication1/WebForm1.aspx Instead, I am recieving results that are something like the following: c:/inetpub/wwwroot/WebApplication1/WebForm1.aspx
3
3986
by: Cozmo | last post by:
We have an .asp application , located in: e:\myapp In there we have directories like: e:\myapp\db e:\myapp\images e:\myapp\utils e:\myapp\working
7
3386
by: benoit | last post by:
Hi, if I write this code to retrieve a folder on the server Server.mappath("/DATA") I get this error message System.InvalidOperationException: Failed to map the path '/DATA' the virtual folder for my webApp is not situated in Inetpub, nor is the DATA folder that I would like to retrieve
3
15062
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named Hello.aspx resides in C:\Inetpub\wwwroot\MyFolder, the output of both Response.Write(Server.MapPath("Hello.aspx")) & Response.Write(Request.MapPath("Hello.aspx"))
0
8584
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8516
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8932
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8768
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6440
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4308
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.