Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to prevent ASP.NET from changing the file extension on SaveAs-Box?

Reply
Thread Tools

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

 
 
Winston
Guest
Posts: n/a
 
      02-07-2004
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
 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      02-07-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      02-08-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
Winston
Guest
Posts: n/a
 
      02-08-2004
"Steve C. Orr [MVP, MCSD]" <(E-Mail Removed)> wrote in message news:<#$(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > 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

 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      02-09-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Steve C. Orr [MVP, MCSD]" <(E-Mail Removed)> wrote in message

news:<#$(E-Mail Removed)>...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > 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



 
Reply With Quote
 
Eric Lawrence [MSFT]
Guest
Posts: n/a
 
      02-11-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Steve C. Orr [MVP, MCSD]" <(E-Mail Removed)> wrote in message

news:<#$(E-Mail Removed)>...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When does a binary extension gets the file extension '.pyd' and whenis it '.so' llothar Python 17 04-07-2008 02:54 AM
How to convert a .txt file extension to a .xls file extension? Steve ASP .Net 3 08-25-2006 05:43 PM
Prevent VS from changing my code Chris Mahoney ASP .Net 5 08-23-2005 10:53 PM
Prevent User From Changing Font Size in FireFox crjunk@earthlink.net HTML 9 07-26-2005 10:34 AM
changing file extension without changing filename jamy Computer Support 4 03-04-2005 01:03 AM



Advertisments