how to force download

Discussion in 'ASP .Net' started by greg, Sep 16, 2005.

  1. greg

    greg Guest

    Hi

    I have a link on a page that points to a file inside the site that I want to
    be downloaded
    loke in page_load I write

    linkFile.NavigateUrl = Request.ApplicationPath + "/somepath/file.iif";

    This file is a text file so when user clicks onthat link it displays in the
    browser
    the contents of that file (it is a text file although with ext iif)

    How do i force browser to display dialog like where to save it?

    Thanks
    GSL
    greg, Sep 16, 2005
    #1
    1. Advertising

  2. Yes, you can force a dialog box that will ask the user whether they'd like
    to open or save the file:

    Response.Clear()
    Response.ContentType = Whatever
    Response.Writefile("c:\whatever.iif")
    Response.AddHeader("Content-Disposition",
    "attachment;filename=whatever.iif")
    Response.End()

    Here are more details:
    http://SteveOrr.net/articles/EasyUploads.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "greg" <> wrote in message
    news:...
    > Hi
    >
    > I have a link on a page that points to a file inside the site that I want
    > to
    > be downloaded
    > loke in page_load I write
    >
    > linkFile.NavigateUrl = Request.ApplicationPath + "/somepath/file.iif";
    >
    > This file is a text file so when user clicks onthat link it displays in
    > the
    > browser
    > the contents of that file (it is a text file although with ext iif)
    >
    > How do i force browser to display dialog like where to save it?
    >
    > Thanks
    > GSL
    >
    >
    Steve C. Orr [MVP, MCSD], Sep 17, 2005
    #2
    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. PJS

    Force Download - XML problem

    PJS, Jul 18, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    505
  2. Ken Cox [Microsoft MVP]

    Re: Force File Download XML Problem

    Ken Cox [Microsoft MVP], Jul 19, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    692
  3. Miguel Dias Moura

    How to force download?

    Miguel Dias Moura, Apr 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    559
    Dan Brussee
    Apr 19, 2004
  4. localhost

    Force Download Not Working

    localhost, Jun 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    352
    Steven Cheng[MSFT]
    Jun 30, 2004
  5. tma

    Force download rather than view

    tma, Aug 7, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    810
    =?Utf-8?B?SmVyZW15IERhdmlz?=
    Aug 8, 2004
Loading...

Share This Page