Downloading/opening file in client application window

Discussion in 'ASP .Net' started by Rob Nicholson, May 12, 2005.

  1. The following code added to Page_Load works a treat:

    Response.ContentType = "application/zip"
    Response.AppendHeader("Content-Disposition", "attachment;
    filename=DesktopChange.pdf")
    Response.WriteFile("C:\Inetpub\wwwroot\Download\DesktopChange.pdf")
    Response.Flush()

    But *only* if the document exists in the web site or is accessible by the
    ASPNET account. However, it fails if the document is stored on the network,
    e.g. s:\temp\desktopchange.pdf. This isn't surprising as the ASPNET can't
    access s:\Temp.

    One workaround we've though of is using the upload file functionality to
    upload from the client to the server into a temporary file and then serve up
    this temporary file.

    But this requires an upload and a download which is waste.

    Anyone got any ideas how to solve this?

    Cheers, Rob.
    Rob Nicholson, May 12, 2005
    #1
    1. Advertising

  2. > One workaround we've though of is using the upload file functionality to
    > upload from the client to the server into a temporary file and then serve

    up
    > this temporary file.


    Ahh, we've realised the flaw in this paragraph as it goes like this:

    BEGIN
    Server knows the name of a file stored either on the client or on a network
    share accessible from the client
    Automatically upload it to the server [A]
    Use Response.AppendHeader("Content-Disposition", "attachment; filename=XYZ")
    to fire it back at the browser
    END

    The flaw is step [A] which is in effect giving the server the ability to
    upload *any* file at will. Dangerous...

    A workaround is to display a popup window which is in effect a <input
    type=file> form which allows the uses to click "Upload" to upload the file
    to the server so the server can then throw it back via
    Response.AppendHeader.

    All very clumsy! This is why I don't like webapps :)

    Rob.
    Rob Nicholson, May 12, 2005
    #2
    1. Advertising

  3. Rob Nicholson

    Sambathraj Guest

    Hi,
    Assuming that you are running on Windows2003, in order that aps.net to
    access the netowork resources, service should be running under network
    service acount. also the folder being accessed should be configured to allow
    the netowrk service account.
    Regards
    Sambathraj
    "Rob Nicholson" <> wrote in message
    news:...
    > The following code added to Page_Load works a treat:
    >
    > Response.ContentType = "application/zip"
    > Response.AppendHeader("Content-Disposition", "attachment;
    > filename=DesktopChange.pdf")
    > Response.WriteFile("C:\Inetpub\wwwroot\Download\DesktopChange.pdf")
    > Response.Flush()
    >
    > But *only* if the document exists in the web site or is accessible by the
    > ASPNET account. However, it fails if the document is stored on the
    > network,
    > e.g. s:\temp\desktopchange.pdf. This isn't surprising as the ASPNET can't
    > access s:\Temp.
    >
    > One workaround we've though of is using the upload file functionality to
    > upload from the client to the server into a temporary file and then serve
    > up
    > this temporary file.
    >
    > But this requires an upload and a download which is waste.
    >
    > Anyone got any ideas how to solve this?
    >
    > Cheers, Rob.
    >
    >
    Sambathraj, May 12, 2005
    #3
  4. Thanks for your posting Rob,

    As for web application, the clientside ability is very restricted and web
    application can't access most of the clientside resource. For example, we
    can't alert or retreive any file on the clientside's local disk.(If not
    using ActiveX control or other strong-typed code) The only means to
    retrieve file stream from clientside is using the <input type="file" ../>
    as you mentioned, this will need the client user to select file
    interactively. So I don't think there will exit any security concern when
    uploading file from client to server.

    In addition, as for your scenario, you'd like to upload file from client to
    server and write out the file to client again as attachment? I'm not sure
    what's your application's detail logic, would you provide some further info
    so that we may have a look to see whether there're any other potential
    approachs?

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], May 13, 2005
    #4
    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. Patrick Olurotimi Ige

    Closing child window when opening a new Window

    Patrick Olurotimi Ige, Dec 14, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    443
    Patrick Olurotimi Ige
    Dec 14, 2004
  2. UJ
    Replies:
    2
    Views:
    7,507
    John Timney \(ASP.NET MVP\)
    Jun 27, 2005
  3. Clara
    Replies:
    6
    Views:
    586
    Clara
    Apr 25, 2005
  4. Allan
    Replies:
    1
    Views:
    107
    Randy Webb
    Aug 6, 2004
  5. Replies:
    4
    Views:
    177
Loading...

Share This Page