Technical support This forum is closed.
Version 1.x > Technical support > Response.Writefile to download a file View modes: 
User avatar
Member
Member
janusz - 8/18/2005 12:08:04 AM
   
Response.Writefile to download a file
Hello!

I have the following code which allows to bring up a file download dialog for the user.

This code has worked before my upgrade to 1.7. Now it does not work and I cannot figure out why.

Response.Clear()
Response.ContentType = "application/octet-stream; name=" & fileName
Response.AddHeader("content-disposition", "attachment; filename=" & fileName)
Response.WriteFile(PathFunctions.GetImportFilesPhysicalPath & "\" & fileName)

Response.End()

The file can be downloaded if I point the browser to correct URL, but cannot be downloaded through this code. Is there any possibility that output filter could affect this functionality? This code is inside the aspx file and triggered during the Page_OnLoad event.

Cheers,

Janusz

User avatar
Guest
admin - 8/18/2005 11:51:57 AM
   
Re: Response.Writefile to download a file
Hi Janusz,

Yes, it is most likely caused by the output filter. You may need to exclude your page from the output filter:

In the global.asax.cs file, please modify the code in the Application_BeginRequest method, on line:

if ( Request.Path.ToLower().IndexOf( "getfile.aspx" ) < 0 && Response.ContentType.ToLower() == "text/html" && ...

(there's already an exception for the getfile.aspx file)

Should you need any help with that, please contact me.

Best Regards,