Problem with downloading files via Content-Disposition

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/19/2012 2:00:50 AM
Gravatar
Total Posts 15

Problem with downloading files via Content-Disposition

Hi,

I am developing a custom file-related extension (as an inline code - ascx from SiteModuleControl) and have some problems with downloading files. A file should be downloaded after the user clicks a download button like this (a very simplified code):

protected void button_Click(object source, EventArgs e)
{
......

Response.ClearContent();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Pragma", "no-cache");
Response.AppendHeader("Content-Disposition", "attachment; filename="+fileName);
Response.AppendHeader("Content-Length", fileInfo.Length.ToString());

Response.WriteFile(fileFullPath);

Response.Close();
Response.End();

}

After I click the button, nothing happens, but the code above works for years in plain ASP.NET.
I suppose that some settings in mojoPortal prevent file streaming to the browser or cache it.

Any help will be highly appreciated. Thanks!

 

3/19/2012 9:32:40 AM
Gravatar
Total Posts 18439

Re: Problem with downloading files via Content-Disposition

Hi,

I suppose that some settings in mojoPortal prevent file streaming to the browser or cache it.

That is a false supposition.

Have you set a breakpoint and stepped through your code?

Are you sure your button click is even firing?

Are you sure no error is happening?

3/19/2012 1:01:34 PM
Gravatar
Total Posts 15

Re: Problem with downloading files via Content-Disposition

Actually, the problem was in the UpdatePanel, I removed it for this module.

Thanks anyway!

You must sign in to post in the forums. This thread is closed to new posts.