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

Discussion in 'ASP .Net' started by TLM, Nov 17, 2004.

  1. TLM

    TLM Guest

    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?
     
    TLM, Nov 17, 2004
    #1
    1. Advertising

  2. TLM

    TLM Guest

    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.
     
    TLM, Nov 17, 2004
    #2
    1. Advertising

  3. TLM

    TLM Guest

    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.
     
    TLM, Nov 17, 2004
    #3
  4. TLM

    Patrice Guest

    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" <> a écrit dans le message de
    news:775801c4ccc2$5be9d7b0$...
    > 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.
    >
    >
     
    Patrice, Nov 17, 2004
    #4
  5. TLM

    TLM Guest

    XP SP2 only

    RETRACTION:

    This behavior does not appear when running the pages on a
    Windows 2000 Pro computer; but does appear on XP SP2
    computers.
     
    TLM, Nov 17, 2004
    #5
  6. TLM

    Patrice Guest

    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" <> a écrit dans le message de
    news:775801c4ccc2$5be9d7b0$...
    > 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.
    >
    >
     
    Patrice, Nov 17, 2004
    #6
  7. 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" <> a écrit dans le message de
    > news:775801c4ccc2$5be9d7b0$...
    > > 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.
    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?VExN?=, Nov 17, 2004
    #7
  8. Re: File://c:/<path> does not display contents: Aditional Info

    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" <> a écrit dans le message de
    > > news:775801c4ccc2$5be9d7b0$...
    > > > 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.
    > > >
    > > >

    > >
    > >
    > >
     
    =?Utf-8?B?VExN?=, Nov 17, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joey
    Replies:
    0
    Views:
    974
  2. Don Adams
    Replies:
    1
    Views:
    609
    Martin Honnen
    Mar 5, 2004
  3. Chris Hare
    Replies:
    6
    Views:
    891
    Chris Hare
    Aug 15, 2010
  4. Kamarulnizam Rahim
    Replies:
    4
    Views:
    231
    Robert Klemme
    Jan 28, 2011
  5. Replies:
    0
    Views:
    205
Loading...

Share This Page