Download text file

Discussion in 'ASP .Net' started by Samuel, Jun 14, 2007.

  1. Samuel

    Samuel Guest

    Hi

    I want to offer people to actually download text file and not view it on
    browser (which is what happens by default)

    Thank you,
    Samuel
    Samuel, Jun 14, 2007
    #1
    1. Advertising

  2. Samuel

    Patrice Guest

    You can force the download control by using :
    http://support.microsoft.com/kb/260519/en-us
    (applies as well to ASP.NET)

    Once thr header is written you can then use Response.WriteFile to stream the
    file to the browser...

    --
    Patrice

    "Samuel" <> a écrit dans le message de news:
    ukZ4$...
    >
    > Hi
    >
    > I want to offer people to actually download text file and not view it on
    > browser (which is what happens by default)
    >
    > Thank you,
    > Samuel
    >
    Patrice, Jun 14, 2007
    #2
    1. Advertising

  3. Samuel

    Samuel Guest

    I added the following code:

    Response.AddHeader("content-disposition", "attachment;
    filename=FileName.txt")

    Response.ClearContent()

    Response.WriteFile("FileName.txt")

    But I get mcuh more content than the text file

    Thank you,
    Samuel



    "Patrice" <http://www.chez.com/scribe/> wrote in message
    news:...
    > You can force the download control by using :
    > http://support.microsoft.com/kb/260519/en-us
    > (applies as well to ASP.NET)
    >
    > Once thr header is written you can then use Response.WriteFile to stream
    > the file to the browser...
    >
    > --
    > Patrice
    >
    > "Samuel" <> a écrit dans le message de news:
    > ukZ4$...
    >>
    >> Hi
    >>
    >> I want to offer people to actually download text file and not view it on
    >> browser (which is what happens by default)
    >>
    >> Thank you,
    >> Samuel
    >>

    >
    >
    Samuel, Jun 15, 2007
    #3
  4. Samuel

    Patrice Guest

    That is ? Make sure also to clear the markup etc.. Basically such a page
    should return anything but your content (i.. you shouldn't return any HTML,
    html code, master pages content etc...). Though it's likely better to clean
    up these elements for clarity a quick way to check this would to use
    Response.end to end the streaming once the file is trnasmitted.

    If the content is no more there this is because your page renders other
    things at a later time (such as HTML markup if you have still this in your
    ASPX page).

    --
    Patrice

    "Samuel" <> a écrit dans le message de news:
    ...
    >I added the following code:
    >
    > Response.AddHeader("content-disposition", "attachment;
    > filename=FileName.txt")
    >
    > Response.ClearContent()
    >
    > Response.WriteFile("FileName.txt")
    >
    > But I get mcuh more content than the text file
    >
    > Thank you,
    > Samuel
    >
    >
    >
    > "Patrice" <http://www.chez.com/scribe/> wrote in message
    > news:...
    >> You can force the download control by using :
    >> http://support.microsoft.com/kb/260519/en-us
    >> (applies as well to ASP.NET)
    >>
    >> Once thr header is written you can then use Response.WriteFile to stream
    >> the file to the browser...
    >>
    >> --
    >> Patrice
    >>
    >> "Samuel" <> a écrit dans le message de news:
    >> ukZ4$...
    >>>
    >>> Hi
    >>>
    >>> I want to offer people to actually download text file and not view it on
    >>> browser (which is what happens by default)
    >>>
    >>> Thank you,
    >>> Samuel
    >>>

    >>
    >>

    >
    >
    Patrice, Jun 15, 2007
    #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. Ryan Taylor
    Replies:
    2
    Views:
    920
    Ryan Taylor
    Nov 10, 2004
  2. Steve C. Orr [MVP, MCSD]
    Replies:
    0
    Views:
    1,588
    Steve C. Orr [MVP, MCSD]
    Mar 7, 2005
  3. Sam --
    Replies:
    2
    Views:
    594
    Sam --
    Mar 17, 2005
  4. Rafal Majda
    Replies:
    5
    Views:
    2,230
    Rafal Majda
    Apr 18, 2005
  5. Brett  Kelly
    Replies:
    1
    Views:
    663
    Steve C. Orr [MVP, MCSD]
    Jun 16, 2006
Loading...

Share This Page