473,322 Members | 1,352 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,322 software developers and data experts.

Simple Server.MapPath problem?

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:

Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\inetpub\wwwroot\ChatSimple\chatusers.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.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
Application("ChatConnString") =
"Provider=Microsoft.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.Write(Application("ChatConnString"))
Response.End %>
</BODY></HTML>

+ + + + + + +

Nov 19 '05 #1
2 3500
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("dbConnString")) - effectively killing the old one.
That worked, but before that, altering the value in the
Application variable did nothing. eg.

Application("ChatConnString") =
"Provider=Microsoft.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.CacheControl = "no-cache" %>
<% Response.Expires = -1 %>

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

The only thing that actually worked

On Wed, 11 May 2005 11:40:01 GMT, Oberon <ob****@solstice.com>
wrote:
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:

Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\inetpub\wwwroot\ChatSimple\chatusers.md b\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.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
Application("ChatConnString") =
"Provider=Microsoft.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.Write(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****@solstice.com> wrote in message
news:68********************************@4ax.com...
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:

Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\inetpub\wwwroot\ChatSimple\chatusers.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.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

Sub Application_Start(ByVal sender As Object, ByVal e As
EventArgs)
Application("ChatConnString") =
"Provider=Microsoft.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.Write(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
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...
7
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...
4
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...
7
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,...
2
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
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...
6
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...
3
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
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...
3
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...
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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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...
1
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....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.