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

File://c:/<path> does not display contents

TLM
I am trying to build a web application that will contain
links to files on a users local computer. I am assuming
that the files will be in a known location and can display
in a browser window.

I have my ASP.NET application building links along the
lines of

file://c:/<path to file>

When I use the link in IE 6.0's address bar, I am able to
see the file as expected. If I use the link on an ordinary
HTML page, I am also able to use the link and receive the
file as expected.

I can refer to pages via file://localhost if (and only if)
they are located in my inetpub/wwwroot directory of a
computer with IIS or PWS (but since I cannot assume that
my users have that, it does not really help). I have
found that once I have called a plain HTML file in this
way, if it has links in the file://c:/<file path> format,
they work normally.

However, when I use the link from within an ASPX page, the
page does not change. I have seen occasionally (but not
always) a bit of a JavaScript message in the status bar
that appears to be some validation firing that simply
redirects me back where I started -- effectively doing
nothing.

So: I know that the failure to display the file is not a
browser issue per se since I can use the File: url in both
the address bar and a plain HTML page. I have a suspicion
that there is some default validation code that prevents
this sort of URL from firing from VS 2003-built ASPX.

I am even able to find the path in the output HTML file
and past that into the IE address bar to navigate to the
file -- I just cannot navigate to it from within the ASPX
page.

I have not found any solid references to this sort of
thing on the net or in my hardcopy books.

I have tried setting validateRequests = "false" without
effect. Same with commenting out references to
vs_defaultClientScript.

I have also tried this from other computers (Win2k, XP
Home, XP Pro), and I have tried using invalid file: URLs
as well (these don't even return a 404 error). Attepting
to 'open in new window' has variously returned the bit of
JavaScript in the address bar and done nothing.

Unfortunately, one or another of the things I have tried
is now preventing the JavaScript from appearing, but as I
recal, it was calling a page_validate method of some sort.

When I put the path as the SRC of an iFrame on an ASPX
file, the frame shows nothing: viewing the source of the
frame shows only a pair of empty <HTML></HTML> tags.

Links using the HTTP:// path work normally; those using
file:// do not. The net effect is that 'nothing' apparent
to the user seems to be happening.

This looks like a security 'feature' albiet an
inconvenient one for me.

Does anyone have any suggestions on how to reference files
on a local computer drive from within an ASPX file?
Nov 18 '05 #1
7 6342
TLM
Aditional information:

1) an ASPX page can be built by other IDEs or by hand
(e.g. Dreamweaver, etc.) and the file://c:/<path name>
will work as expected

2) if the ASPX page is imported into a VS project and run
from within the project, the file://c:/<path name> will
not work (links will fail, page will not be displayed in
an iFrame, etc.). This occurs even if the ULL is hard-
coded rather than generated.

3) if the page is converted to a plain HTML page that is
included as a part of a VS project, the file://c:/<path
name> will not work (links will fail, page will not be
displayed in an iFrame, etc.)

4) if the resulting HTML source from either the plain HTML
or ASPX from the VS project is saved as an independent
HTML file, the file://c:/<path name> will work as expected

=======SAMPLE HTML=================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<html>
<head>
<title>test page</title>
</head>
<body>
<table width="100%" border="0" cellspacing="2"
cellpadding="2" ID="Table1">
<tr>
<td>header</td>
</tr>
<tr>
<td>
<iframe
id="lessonArea" SRC="file://c:/test/test.htm"></iframe>
</td>
</tr>
</table>
</body>
</html>

===================================

So: the problem seems to be an effect of the VS project:
there is something about the ASPX generated by VS that
prevents file://C:/<path name> from firing normally.

This has been seen with both IIS 6 and the PWS that can be
run from an XP Pro computer.
Nov 18 '05 #2
TLM
Additional Information:

Oddly, when the URL is hardcoded in an iFrame (see sample
below), the contents will display in the VS IDE, but not
when the page is actually run.

===== SAMPLE CODE =========
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="Testing.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<table width="100%" border="0"
cellspacing="2" cellpadding="2">
<TBODY>
<tr>

<td>header</td>
</tr>
<tr>
<td>

<iframe id="lessonArea"
SRC="file://c:/test/test.htm" runat="server"></iframe>

<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="file:///C:\test\test.htm">HyperLink</asp:Hyper
Link>
</td>
</tr>
</form>
</TBODY></TABLE>
</body>
</HTML>

===========================

note that a 404 eror is expected if the user does not have
a file at c:\test\test.htm, but what is occuring is that
nothing is displayed and the link just plain does not
appear to fire.
Nov 18 '05 #3
Check the HTML code for the HyperLink client side to see if it is correct.

I doubt you'll have a 404 error for a file that doesn't exist as this is an
HTTP error code and you don't use HTTP when accessing the local file...

Also double check those pesky /// and avoid / and \ confusion...

Good luck

Patrice

--

"TLM" <an*******@discussions.microsoft.com> a écrit dans le message de
news:77****************************@phx.gbl...
Additional Information:

Oddly, when the URL is hardcoded in an iFrame (see sample
below), the contents will display in the VS IDE, but not
when the page is actually run.

===== SAMPLE CODE =========
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="Testing.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<table width="100%" border="0"
cellspacing="2" cellpadding="2">
<TBODY>
<tr>

<td>header</td>
</tr>
<tr>
<td>

<iframe id="lessonArea"
SRC="file://c:/test/test.htm" runat="server"></iframe>

<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="file:///C:\test\test.htm">HyperLink</asp:Hyper
Link>
</td>
</tr>
</form>
</TBODY></TABLE>
</body>
</HTML>

===========================

note that a 404 eror is expected if the user does not have
a file at c:\test\test.htm, but what is occuring is that
nothing is displayed and the link just plain does not
appear to fire.

Nov 18 '05 #4
TLM
RETRACTION:

This behavior does not appear when running the pages on a
Windows 2000 Pro computer; but does appear on XP SP2
computers.
Nov 18 '05 #5
Found also :

Note Internet Explorer 6 Service Pack 1 (SP1) no longer allows browsing a
local machine from the Internet zone. For instance, if an Internet site
contains a link to a local file, Internet Explorer 6 SP1 displays a blank
page when a user clicks on the link. Previous versions of Internet Explorer
followed the link to the local file.

Could it be related to this ?

--

"TLM" <an*******@discussions.microsoft.com> a écrit dans le message de
news:77****************************@phx.gbl...
Additional Information:

Oddly, when the URL is hardcoded in an iFrame (see sample
below), the contents will display in the VS IDE, but not
when the page is actually run.

===== SAMPLE CODE =========
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="Testing.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<table width="100%" border="0"
cellspacing="2" cellpadding="2">
<TBODY>
<tr>

<td>header</td>
</tr>
<tr>
<td>

<iframe id="lessonArea"
SRC="file://c:/test/test.htm" runat="server"></iframe>

<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="file:///C:\test\test.htm">HyperLink</asp:Hyper
Link>
</td>
</tr>
</form>
</TBODY></TABLE>
</body>
</HTML>

===========================

note that a 404 eror is expected if the user does not have
a file at c:\test\test.htm, but what is occuring is that
nothing is displayed and the link just plain does not
appear to fire.

Nov 18 '05 #6
TLM
THank you, Patrice.

This does seem to be somewhat related. I have been continuing to explore
this, and I am finding that the problem occurs on the XP machines in my
network, but not on a Win2K machine.

On one of the XP (SP2) machines, I have installed Firefox (to check if it is
simply an IE thing) and found the same problem.

When I ran a test page through FireFox on the Win2K machine that allows me
to use the file:// path as expected in IE (6.0.2800.1106, SP1), the page pae
failed in Firefox in the same way that it did on the XP SP2 machine.

So, I think that you are correct that this is some sort of security thing. I
am just not clear on precisely what it is or if there is a work around.

It does seem odd that the file:// code will run as expected outside of an
ASPX file (e.g. in an HTML file built from the output of the ASPX and run
outside of the webserver itself).

If the security is attempting to prevent use of the file://c:/<path name>
urls, why only with pages generated in Visual Studio?

"Patrice" wrote:
Found also :

Note Internet Explorer 6 Service Pack 1 (SP1) no longer allows browsing a
local machine from the Internet zone. For instance, if an Internet site
contains a link to a local file, Internet Explorer 6 SP1 displays a blank
page when a user clicks on the link. Previous versions of Internet Explorer
followed the link to the local file.

Could it be related to this ?

--

"TLM" <an*******@discussions.microsoft.com> a écrit dans le message de
news:77****************************@phx.gbl...
Additional Information:

Oddly, when the URL is hardcoded in an iFrame (see sample
below), the contents will display in the VS IDE, but not
when the page is actually run.

===== SAMPLE CODE =========
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="Testing.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<table width="100%" border="0"
cellspacing="2" cellpadding="2">
<TBODY>
<tr>

<td>header</td>
</tr>
<tr>
<td>

<iframe id="lessonArea"
SRC="file://c:/test/test.htm" runat="server"></iframe>

<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="file:///C:\test\test.htm">HyperLink</asp:Hyper
Link>
</td>
</tr>
</form>
</TBODY></TABLE>
</body>
</HTML>

===========================

note that a 404 eror is expected if the user does not have
a file at c:\test\test.htm, but what is occuring is that
nothing is displayed and the link just plain does not
appear to fire.


Nov 18 '05 #7
TLM
Additional Info:

I have since created an ASPX project in DreamWeaver MX to test this.

With IE
On the XP SP2 computer, the problem continues to occur, but does not on the
Win2K computer.

With Firefox
The problem occurs on both the XP and Win2K computers.

"TLM" wrote:
THank you, Patrice.

This does seem to be somewhat related. I have been continuing to explore
this, and I am finding that the problem occurs on the XP machines in my
network, but not on a Win2K machine.

On one of the XP (SP2) machines, I have installed Firefox (to check if it is
simply an IE thing) and found the same problem.

When I ran a test page through FireFox on the Win2K machine that allows me
to use the file:// path as expected in IE (6.0.2800.1106, SP1), the page pae
failed in Firefox in the same way that it did on the XP SP2 machine.

So, I think that you are correct that this is some sort of security thing. I
am just not clear on precisely what it is or if there is a work around.

It does seem odd that the file:// code will run as expected outside of an
ASPX file (e.g. in an HTML file built from the output of the ASPX and run
outside of the webserver itself).

If the security is attempting to prevent use of the file://c:/<path name>
urls, why only with pages generated in Visual Studio?

"Patrice" wrote:
Found also :

Note Internet Explorer 6 Service Pack 1 (SP1) no longer allows browsing a
local machine from the Internet zone. For instance, if an Internet site
contains a link to a local file, Internet Explorer 6 SP1 displays a blank
page when a user clicks on the link. Previous versions of Internet Explorer
followed the link to the local file.

Could it be related to this ?

--

"TLM" <an*******@discussions.microsoft.com> a écrit dans le message de
news:77****************************@phx.gbl...
Additional Information:

Oddly, when the URL is hardcoded in an iFrame (see sample
below), the contents will display in the VS IDE, but not
when the page is actually run.

===== SAMPLE CODE =========
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="Testing.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<table width="100%" border="0"
cellspacing="2" cellpadding="2">
<TBODY>
<tr>

<td>header</td>
</tr>
<tr>
<td>

<iframe id="lessonArea"
SRC="file://c:/test/test.htm" runat="server"></iframe>

<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="file:///C:\test\test.htm">HyperLink</asp:Hyper
Link>
</td>
</tr>
</form>
</TBODY></TABLE>
</body>
</HTML>

===========================

note that a 404 eror is expected if the user does not have
a file at c:\test\test.htm, but what is occuring is that
nothing is displayed and the link just plain does not
appear to fire.


Nov 18 '05 #8

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

Similar topics

3
by: Haim Ashkenazi | last post by:
Hi I have to write a function that returns a list of all directories under <PATH> (should work on linux and windows). it should be easy to write a loop that goes through every directory... and...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
1
by: Alex VanderWoude | last post by:
I am trying to <include> some text into an XML documentation topic, but that text is stored in a file that is in a different directory than the "current" XML file. Using a relative path does not...
4
by: Carsten Kraft | last post by:
Hello Newsgroup, I am searching for function which returns me filename from a string that has the file + filepath. ( string sFile = "C:\DIR\SUBDIR\TEST.XML" => TEST.XML) Is there a...
0
by: Rob | last post by:
Hope you can help me on this one. The scenario is this - i have integrated VS.NET with VSS and am now trying to set-up an automated build script which does the following: 1) Labels most recent...
10
by: Andrew Backer | last post by:
I have a few file:///c:/windows/somewhere style uris that I need to convert to the actual physical path. I am hoping there is a built in way to handle this. I know I can do some text replacing...
1
by: dryajov | last post by:
Hi I'm not sure if this should go here in the first place, this is more likely an ODBC driver issue. I'm having the strangest behavior when trying to do an insert into an access database from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...

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.