[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1017
  • Last Modified:

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

0
ryanmauldin
Asked:
ryanmauldin
  • 2
1 Solution
 
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
 
Michel PlungjanIT 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
 
ryanmauldinAuthor Commented:
that sounds right I will try it out.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now