Technical support This forum is closed.
Version 1.x > Technical support > Cannot stream a download when using Kentico 1.7a View modes: 
User avatar
Member
Member
cpaul - 12/2/2005 10:27:52 PM
   
Cannot stream a download when using Kentico 1.7a
After upgrading my site to 1.7a, the pages I have that download files to the client no longer work, and after trying several different methods I still cannot get it to work.

Code such as the following:

private void Page_Load(object sender, System.EventArgs e)
{
string sequence = "aoeu";
Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("Content-Disposition","attachment; filename=sequence.fasta");
Response.ContentType="text/fasta";
Response.AddHeader ("Content-Length", sequence.Length.ToString());
Response.Output.Write(sequence);
Response.End();
}

Works fine in an empty project and in my live 1.6 based site. The same code put into my 1.7a project sends the following (obtained by telnetting to port 80)

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Fri, 02 Dec 2005 21:25:57 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Content-Disposition: attachment; filename=sequence.fasta
Cache-Control: private
Content-Type: text/fasta; charset=utf-8
Content-Length: 4

Connection closed by foreign host.

I tried disabling some features I thought might be responsible...
<add key="CMSUseOutputFilter" value="false" />
<add key="CMSFixFormAction" value="false" />
<add key="CMSFixXHTML" value="false" />
But the behavior persists.

Any ideas?

User avatar
Member
Member
cpaul - 12/2/2005 11:20:44 PM
   
Re: Cannot stream a download when using Kentico 1.7a
I investigated the operation of GetFile.aspx, and I found that the version in my app directory does not work, though the version in the cmsdesk application does (I'm configured in seprate applications to work around the Kentico login and secured areas).

User avatar
Guest
admin - 12/5/2005 6:45:58 PM
   
Re: Cannot stream a download when using Kentico 1.7a
Hi Chip,

could you please try to debug the application, navigate to the page and see if the code is run?

Thank you.

Best Regards,

User avatar
Member
Member
cpaul - 12/5/2005 7:57:54 PM
   
Re: Cannot stream a download when using Kentico 1.7a
Yes, the code is run all the way through without an exception.

If I omit the Response.End() call, I get the expected output, followed by the content of the aspx page.

If I include Response.End() I get no content after the HTTP headers.

User avatar
Member
Member
cpaul - 12/5/2005 8:09:04 PM
   
Re: Cannot stream a download when using Kentico 1.7a
I was able to get the download to work by commenting the following lines out of Application_BeginRequest() in Global.asax.cs:

if ( Request.Path.ToLower().IndexOf( "getfile.aspx" ) < 0 && Response.ContentType.ToLower() == "text/html" && Strings.InStr( HttpContext.Current.Request.Url.AbsolutePath.ToLower(), "/cmsdesk", (Microsoft.VisualBasic.CompareMethod)(0) ) == 0 && Request.Path.ToLower().IndexOf( "syncserver.asmx" ) < 0 )
{
Response.Filter = new Kentico.CMS.CMSOutputFilter.OutputFilter( Response.Filter );
}

I suppose I could add another hardcoded comparison into that if statement instead of commenting it out altogether. I'm really not sure what the output filter does, and I really don't understand why disabling it in the Web.config did not fix the issue.

User avatar
Guest
admin - 12/6/2005 9:08:59 AM
   
Re: Cannot stream a download when using Kentico 1.7a
Hi Chip,

Thank you for your message. I'm not sure why switching off the output filter in the web.config didn't work. However, the output filter is necessary so that the postbacks work correctly on URL rewrited pages.

I would recommend you modifying the code you have commented out so that it excludes your page as it does with getfile.aspx.

Version 1.8 will allow you to exclude paths from both URLRewriting and from the output filter which should help you solve such issues more easily.

Best Regards,