How to prevent ASP.NET from changing the file extension on SaveAs-Box?

Discussion in 'ASP .Net' started by Winston, Feb 7, 2004.

  1. Winston

    Winston Guest

    Hi Group,
    in my aspx page there is an Response.Redirect to a file called myfile.csv.
    The file consists of plain text with comma separated values.
    I want that the browser opens the save as dialog which it does.
    So far so good.

    But the filename, the Internet Explorer suggests is not myfile.csv but myfile.xls.
    Why does the IE change the file extension?

    How can I have the save as dialog with the correct suggestion of the filename?

    Any help appreciated,
    Winston
     
    Winston, Feb 7, 2004
    #1
    1. Advertising

  2. Winston,
    You can probably try to alter the MIME types on the server, but if
    you're redirecting to a csv there probably isn't much. IE is probably
    identifying the csv with Excel since it is a commonly used file to import
    data into Excel or out of it. You can try something like identifying a MIME
    type of csv to application/octet-stream so that IE will hopefully be forced
    to download it.


    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "Winston" <> wrote in message
    news:...
    > Hi Group,
    > in my aspx page there is an Response.Redirect to a file called myfile.csv.
    > The file consists of plain text with comma separated values.
    > I want that the browser opens the save as dialog which it does.
    > So far so good.
    >
    > But the filename, the Internet Explorer suggests is not myfile.csv but

    myfile.xls.
    > Why does the IE change the file extension?
    >
    > How can I have the save as dialog with the correct suggestion of the

    filename?
    >
    > Any help appreciated,
    > Winston
     
    Mark Fitzpatrick, Feb 7, 2004
    #2
    1. Advertising

  3. Some code like this should do the trick.
    Response.AddHeader("Content-Disposition","attachment;filename=myfile.csv");

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


    "Winston" <> wrote in message
    news:...
    > Hi Group,
    > in my aspx page there is an Response.Redirect to a file called myfile.csv.
    > The file consists of plain text with comma separated values.
    > I want that the browser opens the save as dialog which it does.
    > So far so good.
    >
    > But the filename, the Internet Explorer suggests is not myfile.csv but

    myfile.xls.
    > Why does the IE change the file extension?
    >
    > How can I have the save as dialog with the correct suggestion of the

    filename?
    >
    > Any help appreciated,
    > Winston
     
    Steve C. Orr [MVP, MCSD], Feb 8, 2004
    #3
  4. Winston

    Winston Guest

    "Steve C. Orr [MVP, MCSD]" <> wrote in message news:<#$>...
    > Some code like this should do the trick.
    > Response.AddHeader("Content-Disposition","attachment;filename=myfile.csv");
    >



    Hi Steve,
    unfortunately not. I tried it and the IE still changes the file
    extension from .csv to .xls. Any ideas?

    Winston



    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    >
    >
    > "Winston" <> wrote in message
    > news:...
    > > Hi Group,
    > > in my aspx page there is an Response.Redirect to a file called myfile.csv.
    > > The file consists of plain text with comma separated values.
    > > I want that the browser opens the save as dialog which it does.
    > > So far so good.
    > >
    > > But the filename, the Internet Explorer suggests is not myfile.csv but

    > myfile.xls.
    > > Why does the IE change the file extension?
    > >
    > > How can I have the save as dialog with the correct suggestion of the

    > filename?
    > >
    > > Any help appreciated,
    > > Winston
     
    Winston, Feb 8, 2004
    #4
  5. Excel is the default application associated with CSV files.
    But it seems you don't want your CSV files associated with Excel?
    Can you use another extension besides CSV?

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



    "Winston" <> wrote in message
    news:...
    > "Steve C. Orr [MVP, MCSD]" <> wrote in message

    news:<#$>...
    > > Some code like this should do the trick.
    > >

    Response.AddHeader("Content-Disposition","attachment;filename=myfile.csv");
    > >

    >
    >
    > Hi Steve,
    > unfortunately not. I tried it and the IE still changes the file
    > extension from .csv to .xls. Any ideas?
    >
    > Winston
    >
    >
    >
    > > --
    > > I hope this helps,
    > > Steve C. Orr, MCSD, MVP
    > > http://Steve.Orr.net
    > >
    > >
    > > "Winston" <> wrote in message
    > > news:...
    > > > Hi Group,
    > > > in my aspx page there is an Response.Redirect to a file called

    myfile.csv.
    > > > The file consists of plain text with comma separated values.
    > > > I want that the browser opens the save as dialog which it does.
    > > > So far so good.
    > > >
    > > > But the filename, the Internet Explorer suggests is not myfile.csv but

    > > myfile.xls.
    > > > Why does the IE change the file extension?
    > > >
    > > > How can I have the save as dialog with the correct suggestion of the

    > > filename?
    > > >
    > > > Any help appreciated,
    > > > Winston
     
    Steve C. Orr [MVP, MCSD], Feb 9, 2004
    #5
  6. Is there a public URL that you've got this code running on? I'd like to
    look at the Headers.

    --
    Thanks,

    Eric Lawrence
    Program Manager
    Assistance and Worldwide Services

    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Winston" <> wrote in message
    news:...
    > "Steve C. Orr [MVP, MCSD]" <> wrote in message

    news:<#$>...
    > > Some code like this should do the trick.
    > >

    Response.AddHeader("Content-Disposition","attachment;filename=myfile.csv");
    > >

    >
    >
    > Hi Steve,
    > unfortunately not. I tried it and the IE still changes the file
    > extension from .csv to .xls. Any ideas?
    >
    > Winston
    >
    >
    >
    > > --
    > > I hope this helps,
    > > Steve C. Orr, MCSD, MVP
    > > http://Steve.Orr.net
    > >
    > >
    > > "Winston" <> wrote in message
    > > news:...
    > > > Hi Group,
    > > > in my aspx page there is an Response.Redirect to a file called

    myfile.csv.
    > > > The file consists of plain text with comma separated values.
    > > > I want that the browser opens the save as dialog which it does.
    > > > So far so good.
    > > >
    > > > But the filename, the Internet Explorer suggests is not myfile.csv but

    > > myfile.xls.
    > > > Why does the IE change the file extension?
    > > >
    > > > How can I have the save as dialog with the correct suggestion of the

    > > filename?
    > > >
    > > > Any help appreciated,
    > > > Winston
     
    Eric Lawrence [MSFT], Feb 11, 2004
    #6
    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. Alex Pet
    Replies:
    0
    Views:
    1,401
    Alex Pet
    Jan 20, 2004
  2. Jeffrey A. Voigt

    Possible to do a File SaveAs Dialog In ASP.NET

    Jeffrey A. Voigt, Jun 16, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    5,727
    Jeffrey A. Voigt
    Jun 17, 2004
  3. Steve
    Replies:
    3
    Views:
    27,070
    Steve
    Aug 25, 2006
  4. Dan Sikorsky

    HOWTO: Force the SaveAs Dialog Box For Downloads

    Dan Sikorsky, Apr 20, 2004, in forum: ASP General
    Replies:
    3
    Views:
    255
    Dan Sikorsky
    Apr 21, 2004
  5. Martin Mrazek
    Replies:
    0
    Views:
    180
    Martin Mrazek
    May 18, 2004
Loading...

Share This Page