locked
Custom Control Render Problem with Response Header RRS feed

  • Question

  • User-1501923300 posted

    I developed a Asp.Net Custom control (Inherits from CompositeControl) to export the SSRS reports as per given parameters. Inisde of this Asp.net custom control I am calling another assembly which will do the render process of  SQL Server Reporting service reports.  After rendering the report rendered bytes will add to the Current Response header.

    After Rendering Response Header adding code:

    ------------ After render the report into bytes (_reportBytesData) .......

     System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.Clear();

    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName); System.Web.HttpContext.Current.Response.AddHeader("Content-Length", reportBytesData.Length.ToString());

    System.Web.HttpContext.Current.Response.ContentType = mimeType; System.Web.HttpContext.Current.Response.BinaryWrite(_reportBytesData);

    System.Web.HttpContext.Current.Response.Flush();

     

    After adding the Response header process will come out from the assembly. Then custom control override render method will execute.

    protected override void Render(HtmlTextWriter writer)

    {

    base.Render(writer);

    }

     If the rendered file size is smaller then those are showing in my asp.net page. But if the render file size(reportBytesData) is more than 5MB(approximately) it is giving following message

    "Internet Explorer cannot display the webpage"

    If anybody knows the solutions please help me.........

    Thanks,

    Hanu

     

    Thursday, July 10, 2008 10:46 AM

Answers

  • User481221548 posted

    Hi Hanu

    Why not. Use a Library Project in Visual Studio and write your Handler as Class that is deriving from "IHttpHandler".
    Then register the HttpHandler with the Namespace- and Assemblyname. Thats it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 11, 2008 7:02 AM

All replies

  • User-16411453 posted

    Once the header downloads to the client, that's it. You can't change the header and download it again.  You can make changes to the body, but only append to it.

    Looks like a download file to me, there are other ways to trigger a download off the same page, without modifying the page.

    Thursday, July 10, 2008 4:00 PM
  • Thursday, July 10, 2008 6:30 PM
  • User-16411453 posted

     Guess I probably am wrong on that.  My Bad.  Read the article you suggested, and I have a better idea of what you are talking about. I'll let you handle this one Peter, out of my realm.

    Thursday, July 10, 2008 7:37 PM
  • User-1501923300 posted

    Hi Peter,

    As per my requirement I need to use seperate assembly to add the Response header. So I can't impliment Httphandler to add the reposnse header.

     

    Regards,

    Hanu

    Friday, July 11, 2008 12:20 AM
  • User481221548 posted

    Hi Hanu

    Why not. Use a Library Project in Visual Studio and write your Handler as Class that is deriving from "IHttpHandler".
    Then register the HttpHandler with the Namespace- and Assemblyname. Thats it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 11, 2008 7:02 AM
  • User-16411453 posted
    I think your trying to make download code.  This is my code in vb.  If not, I have still misread your post.

     

    Protected Sub lbMenuNavDoc_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    
    	DownloadProgram("MenuNavigationControlV1.pdf")
    
    End Sub
     
    Private Sub DownloadProgram(ByVal ProgramFile As String)
    
    	Response.ContentType = "application/octet-stream"
    	Response.AppendHeader("Content-Disposition", "attachment; filename=" & ProgramFile)
    	Response.TransmitFile(Server.MapPath("~/SoftwarePrograms/Programs/" & ProgramFile))
    	Response.End()
    
    End Sub
    Private Sub DownloadPDF(ByVal PDFFile As String)
    
    	Response.ContentType = "application/octet-stream"
    	Response.AppendHeader("Content-Disposition", "attachment; filename=" & PDFFile)
    	Response.TransmitFile(Server.MapPath("~/SoftwarePrograms/Programs/" & PDFFile))
    	Response.End()
    
    End Sub
     
    Friday, July 11, 2008 2:22 PM
  • User481221548 posted

    Hi jkrkerx

    Thats exactly what not should be used.
    Use an HttpHandler instead (see article above).

    Friday, July 11, 2008 7:17 PM