Link to home
Start Free TrialLog in
Avatar of ryanmauldin
ryanmauldin

asked on

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

Avatar of MrAgile
MrAgile
Flag of Australia image

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

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

ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ryanmauldin
ryanmauldin

ASKER

that sounds right I will try it out.