FireFox Streams the ASX file instead of offering a file download dialog box like IE

I am wanting to offer users of my application the ability to download asx files, edit and play them in a Windows Media Player HTML object. The JavaScript works as expected in IE. The application determines the browser type to decide the correct declaration of the WMP object and everything works fine in IE / Firefox... except the problem I face is that FireFox plays the file... and then you have to click File... Save Page As... to save the .ASX file instead of just offering a simple download prompt. Is their any parameters I can pass in to open a new window as a file download instead of playable content? Do I need to create a seperate ASP.NET page called Download.aspx?... that offers asx, and other media files up as content... Any good examples of this?
onclick="javascript:window.open('http://localhost:4978/MediaCenter/media/SamplePlaylist.asx');"

Open in new window

LVL 1
ryanmauldinAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
and then no need to use window.open

<a href="http://localhost:4978/sendPlayList.aspx?file=MediaCenter/media/SamplePlaylist.asx');">Download file</a>
0
 
MrAgileCommented:
Hi,

If I understand it right, you want to download a file (not open it) when you click a button. Check this out:

sean

 
 
string URL = @"
FileInfo" target=_blank>http://.../myFileToDownload.txt";
FileInfo fileInfo = new FileInfo(URL);
 
if (fileInfo.Exists)
{
 Response.Clear();
 Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
 Response.AddHeader("Content-Length", fileInfo.Length.ToString());
 Response.ContentType = "application/octet-stream";
 Response.Flush();
 Response.WriteFile(fileInfo.FullName);
}

Open in new window

0
 
MrAgileCommented:
Oops!
string URL = "your_url";
FileInfo fileInfo = new FileInfo(URL);
 
if (fileInfo.Exists)
{
 Response.Clear();
 Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
 Response.AddHeader("Content-Length", fileInfo.Length.ToString());
 Response.ContentType = "application/octet-stream";
 Response.Flush();
 Response.WriteFile(fileInfo.FullName);
}
--

Open in new window

0
 
ryanmauldinAuthor Commented:
that sounds right I will try it out.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.