Thread: Re: streaming reports from report services
Brought to you by:
wrowe
From: David M. <wo...@su...> - 2008-10-20 20:06:52
|
<HTML> <P>Thanks, Joe. I sent a question to the mod-aspdotnet-users list. I guess you're subscribed, too.</P> <P>I do ASP.NET development on my workstation. If that was all I'd just keep using IIS. Works good for that. But I'm starting to do PHP development, too. No problem getting PHP to run on IIS, either.</P> <P>For PHP I'm using Eclipse with a plug-in, and it's integrated with Apache. I need to get everything to work on Apache if possible.</P> <P>I have no problem serving any of my applications created with Visual Web Developer 2005, except streaming reports. The report is created, but when it tries to stream out, the page says the server is not configured properly. In code he response is cleared, an attachment header written, the byte content of the report written, then the response is closed. This is how I do it through IIS. I may have to do it differently through Apache.</P> <P>So, I want to use Apache for PHP development, but I also need Apache to serve out my ASP.NET applications that have streaming reports.</P> <P><BR> -- <BR> dgm <BR> <BR> <BR> <B>On Mon Oct 20 11:59 , 'Bigjoe11a' <BIG...@GM...>sent:<BR> <BR> </P></B> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px"><DEFANGED_META content="text/html; charset=iso-8859-1" http-equiv="Content-Type"><DEFANGED_META content="IncrediMail 1.0" name="GENERATOR"><DEFANGED_BODY style="BACKGROUND-POSITION: left 0px; FONT-SIZE: 12pt; MARGIN: 0px 10px 10px; COLOR: #00005b; BACKGROUND-REPEAT: repeat; FONT-FAMILY: Arial" ORGYPOS="0" SIGCOLOR="0" scroll="yes" background="mime.pl?file=BackGrnd-1.jpg" bgColor="#eff3f7" text="#00005b"> <TABLE id=INCREDIMAINTABLE cellSpacing=0 cellPadding=2 width="100%" border=0> <TBODY> <TR> <TD id=INCREDITEXTREGION style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12pt; PADDING-BOTTOM: 0px; CURSOR: auto; PADDING-TOP: 0px" vAlign=top width="100%"> <DIV>Ok, David, I have no idea why your sending this too me. Your going to have to give me an idea why.</DIV> <DIV> </DIV> <DIV>Any way you have to remember that Apache doesn't support asp.net 2.0. How ever Apache does run asp.net 2.0. But it very limited on what it will do.</DIV> <DIV> </DIV> <DIV>You should do is download Cassni Web Server. It supports ASP.NET 2.0 and Ajax.</DIV> <DIV> </DIV> <DIV>I won't run asp.net 2.0 on Apache..</DIV> <DIV> </DIV> <DIV>Use Cassini Web Server.</DIV> <DIV> </DIV> <DIV>Thanks</DIV> <DIV>Joe</DIV> <DIV> </DIV></TD></TR> <TR> <TD id=INCREDIFOOTER width="100%"></TD></TR></TBODY></TABLE></BLOCKQUOTE></HTML> <BR> |
From: David M. <wo...@su...> - 2008-10-21 14:08:43
|
<HTML> <P>I have pasted the error page source as well as the code that creates the report. The code fails with "response.end()". The exception message is "Thread was being aborted."</P> <P> </P> <P><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><BR> <html><head><BR> <title>200 OK</title><BR> </head><body><BR> <h1>OK</h1><BR> <p>The server encountered an internal error or<BR> misconfiguration and was unable to complete<BR> your request.</p><BR> <p>Please contact the server administrator,<BR> <A href="mailto:dav...@dh...">xxxxxxxxxxxxx</A> and inform them of the time the error occurred,<BR> and anything you might have done that may have<BR> caused the error.</p><BR> <p>More information about this error may be available<BR> in the server error log.</p><BR> </body></html><BR> </P> <P> Private Sub OnCallReport(ByVal tit$, ByVal sql$, ByVal connect As Data.SqlClient.SqlConnection)<BR> Dim wr As IO.TextWriter<BR> wr = IO.File.AppendText("c:\OnCallReport.txt")<BR> wr.WriteLine(Format(Now, "MM/dd/yy hh:mm:ss") & " report start")<BR> wr.Close()<BR> Try<BR> UserLog("report", "OnCallReport:" & tit, ui.UserID, Request, connect)<BR> Dim localReport As New Microsoft.Reporting.WebForms.LocalReport<BR> localReport.ReportPath = Server.MapPath("~/OnCallReport01.rdlc")<BR> Dim command As New Data.SqlClient.SqlCommand(sql & " ORDER BY InSort", connect)<BR> Dim reader As Data.SqlClient.SqlDataReader = command.ExecuteReader<BR> localReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_DataTable1", reader))<BR> Dim parameter() As Microsoft.Reporting.WebForms.ReportParameter = {New Microsoft.Reporting.WebForms.ReportParameter("Report_Parameter_0", tit)}<BR> localReport.SetParameters(parameter)<BR> SubReportConnect = New Data.SqlClient.SqlConnection(DefaultConnect)<BR> SubReportConnect.Open()<BR> SubReportCommand = New Data.SqlClient.SqlCommand("", SubReportConnect)<BR> AddHandler localReport.SubreportProcessing, AddressOf OnCallReportSubreportProcessingEventHandler<BR> Dim bytes As Byte() = localReport.Render("PDF", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)<BR> If Not IsNothing(SubReportReader) Then SubReportReader.Close()<BR> SubReportReader = Nothing<BR> SubReportConnect.Close()<BR> SubReportConnect = Nothing<BR> reader.Close()<BR> reader = Nothing<BR> Response.Clear()<BR> Response.ContentType = ""<BR> Response.AddHeader("content-disposition", "attachment; filename=OnCallReport.pdf")<BR> Response.BinaryWrite(bytes)<BR> Response.End()<BR> wr = IO.File.AppendText("c:\OnCallReport.txt")<BR> wr.WriteLine(Format(Now, "MM/dd/yy hh:mm:ss") & " report finish")<BR> wr.Close()<BR> Catch ex As Exception<BR> Dim a$ = ""<BR> Try<BR> a = ex.InnerException.Message<BR> Catch<BR> a = ""<BR> End Try<BR> If Len(a) > 0 Then a = "; " & a<BR> wr = IO.File.AppendText("c:\OnCallReport.txt")<BR> wr.WriteLine(Format(Now, "MM/dd/yy hh:mm:ss") & " " & ex.Message & a)<BR> wr.Close()<BR> End Try<BR> wr.Close()<BR> <BR> <BR> -- <BR> dgm <BR> <BR> <BR> <B>On Mon Oct 20 15:45 , 'William A. Rowe, Jr.' <WR...@RO...>sent:<BR> <BR> </B></P> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px">David McDivitt wrote:<BR> <SPAN style="COLOR: #ff0000">> I have applications written in Visual Web Developer 2005 that work fine,</SPAN><BR> <SPAN style="COLOR: #ff0000">> except for streaming reports. This works fine on IIS and I want it to</SPAN><BR> <SPAN style="COLOR: #ff0000">> work on Apache. A PDF is streamed to the client and the "open, save,</SPAN><BR> <SPAN style="COLOR: #ff0000">> cancel" dialog appears.</SPAN><BR> <BR> Exactly what failure information do you receive, and where (app logs,<BR> apache error logs, client side messages)?<BR> <BR> </BLOCKQUOTE></HTML> <BR> |
From: David M. <wo...@su...> - 2008-10-21 14:41:32
|
<HTML> <P>I ran the report from IIS again with the same debug information. The same error occurs with IIS as the server, but the report streams out anyway. I guess IIS processes whatever content is generated immediately, then attempts to close the response as told to do in the code, and because a valid stream has been received at the client, the client renders it. There is no indication an error occurred because there's no response stream or anything left to write the error description, and the thread just goes away. But with Apache, the response is not being controlled so discreetly.</P> <P>What I can do is completely substitute output by overriding the Render event for the page. Now I am ending the response abruptly without knowing an error was occurring. Instead I should substitute the report into the response and allow ASP.NET to close the thread normally.<BR> <BR> -- <BR> dgm <BR> <BR> <BR> <B>On Mon Oct 20 18:50 , 'William A. Rowe, Jr.' <WR...@RO...>sent:<BR> <BR> </P></B> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px">Bigjoe11a wrote:<BR> <SPAN style="COLOR: #ff0000">> </SPAN><BR> <SPAN style="COLOR: #ff0000">> << Because ajax is 'bursty'</SPAN><BR> <SPAN style="COLOR: #ff0000">> I have no idea what you mean by this.</SPAN><BR> <BR> The response isn't closed... it keeps sending incremental parts of<BR> the same page as a single response.<BR> <BR> -------------------------------------------------------------------------<BR> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge<BR> Build the coolest Linux based applications with Moblin SDK & win great prizes<BR> Grand prize is a trip for two to an Open Source event anywhere in the world<BR> <A href="parse.pl?redirect=http%3A%2F%2Fmoblin-contest.org%2Fredirect.php%3Fbanner_id%3D100%26url%3D%2F" target=_blank><SPAN style="COLOR: #ff0000">http://moblin-contest.org/redirect.php\?banner_id=100&url=/</SPAN></A><BR> _______________________________________________<BR> Mod-aspdotnet-users mailing list<BR> <A href="javascript:top.opencompose('Mod...@li...','','','')">Mod...@li...</A><BR> <A href="parse.pl?redirect=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fmod-aspdotnet-users" target=_blank><SPAN style="COLOR: #ff0000">https://lists.sourceforge.net/lists/listinfo/mod-aspdotnet-users</SPAN></A><BR> </BLOCKQUOTE></HTML> <BR> |
From: David M. <wo...@su...> - 2008-10-21 16:24:22
|
<HTML> <P>I'm getting there but still don't have it. Instead of using the END method on the response I used FLUSH followed with CLOSE. The report did stream to the client at that point, and the open, save, cancel dialog appeared. But when I clicked open, Adobe said the report was corrupted. Upon examining with notepad, the entire report was there, but followed with page output beginning with doctype and the whole nine yards. If deleted from the file, Adobe would display the report just fine!</P> <P>So I tried to see if I could stop output of the page. Obviously the CLOSE method on the response is not really closing the socket as the documentation says. I declared a common boolean value to be set by the report method, and if found in the render method, rendering was skipped. That does not work. Unless the page is allowed to render in the normal fashion, Apache sends an error page to the client saying the server is misconfigured. I tried substituting report content at the point of rendering, but get the same Apache error page.</P> <P>It would seem Apache is buffering the output and only sends the output if constructed properly. Otherwise it sends nothing generated by ASP.NET and sends the error page instead.</P> <P>I don't know how Apache knows whether the ASP.NET page did a normal page rendering. If bytes are written to the response, that should be the way it is. Apache must be examining the outgoing headers. But, Apache must not be examining the start of the stream, but the entire stream, since Apache let the stream pass even if normal page rendering was at the end.</P> <P>To resolve this I need to know exactly what Apache needs to see in the stream to approve it. I can also cancel normal page rendering, to leave the report, only. Maybe Apache doesn't allow the kind of stream I'm trying to write. Is there a validation feature I can turn off?<BR> <BR> -- <BR> dgm <BR> <BR> <BR> <B>On Tue Oct 21 9:41 , David McDivitt <WO...@SU...>sent:<BR> <BR> </P></B> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px"> <P>I ran the report from IIS again with the same debug information. The same error occurs with IIS as the server, but the report streams out anyway. I guess IIS processes whatever content is generated immediately, then attempts to close the response as told to do in the code, and because a valid stream has been received at the client, the client renders it. There is no indication an error occurred because there's no response stream or anything left to write the error description, and the thread just goes away. But with Apache, the response is not being controlled so discreetly.</P> <P>What I can do is completely substitute output by overriding the Render event for the page. Now I am ending the response abruptly without knowing an error was occurring. Instead I should substitute the report into the response and allow ASP.NET to close the thread normally.<BR> <BR> -- <BR> dgm <BR> </P></BLOCKQUOTE></HTML> <BR> |
From: David M. <wo...@su...> - 2008-10-21 18:39:11
|
<HTML> <P>Pasted below is how I resolved my issue. Setting the CONTENTTYPE property on the response took care of it. A boolean is declared at top then tested in the render routine. FLUSH, CLOSE, and END should not be used since everything will happen correctly as page processing is allowed to complete normally. Thanks for the assistance.</P> <P> Private NoRender As Boolean = False</P> <P> Private Sub OnCallReport(ByVal tit$, ByVal sql$, ByVal connect As Data.SqlClient.SqlConnection)<BR> UserLog("report", "OnCallReport:" & tit, ui.UserID, Request, connect)<BR> Dim localReport As New Microsoft.Reporting.WebForms.LocalReport<BR> localReport.ReportPath = Server.MapPath("~/OnCallReport01.rdlc")<BR> Dim command As New Data.SqlClient.SqlCommand(sql & " ORDER BY InSort", connect)<BR> Dim reader As Data.SqlClient.SqlDataReader = command.ExecuteReader<BR> localReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_DataTable1", reader))<BR> Dim parameter() As Microsoft.Reporting.WebForms.ReportParameter = {New Microsoft.Reporting.WebForms.ReportParameter("Report_Parameter_0", tit)}<BR> localReport.SetParameters(parameter)<BR> SubReportConnect = New Data.SqlClient.SqlConnection(DefaultConnect)<BR> SubReportConnect.Open()<BR> SubReportCommand = New Data.SqlClient.SqlCommand("", SubReportConnect)<BR> AddHandler localReport.SubreportProcessing, AddressOf OnCallReportSubreportProcessingEventHandler<BR> Dim bytes As Byte() = localReport.Render("PDF", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)<BR> If Not IsNothing(SubReportReader) Then SubReportReader.Close()<BR> SubReportReader = Nothing<BR> SubReportConnect.Close()<BR> SubReportConnect = Nothing<BR> reader.Close()<BR> reader = Nothing<BR> Response.Clear()<BR> Response.ContentType = "application/x-pdf"<BR> Response.AddHeader("content-disposition", "attachment; filename=OnCallReport.pdf")<BR> Response.BinaryWrite(bytes)<BR> NoRender = True<BR> End Sub</P> <P> Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)<BR> If NoRender Or (Not Response.IsClientConnected) Then<BR> writer = Nothing<BR> Exit Sub<BR> End If<BR> writer.InnerWriter.Close()<BR> Dim sw As New IO.StringWriter<BR> writer.InnerWriter = sw<BR> MyBase.Render(writer)<BR> writer.Close()<BR> Response.Write(EditMenu(sw.ToString))<BR> End Sub<BR> </P> <P><BR> <BR> -- <BR> dgm <BR> <BR> <BR> <B>On Tue Oct 21 11:24 , David McDivitt <WO...@SU...>sent:<BR> <BR> </B></P> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #f5f5f5 2px solid; MARGIN-RIGHT: 0px"> <P>I'm getting there but still don't have it. Instead of using the END method on the response I used FLUSH followed with CLOSE. The report did stream to the client at that point, and the open, save, cancel dialog appeared. But when I clicked open, Adobe said the report was corrupted. Upon examining with notepad, the entire report was there, but followed with page output beginning with doctype and the whole nine yards. If deleted from the file, Adobe would display the report just fine!</P> <P>So I tried to see if I could stop output of the page. Obviously the CLOSE method on the response is not really closing the socket as the documentation says. I declared a common boolean value to be set by the report method, and if found in the render method, rendering was skipped. That does not work. Unless the page is allowed to render in the normal fashion, Apache sends an error page to the client saying the server is misconfigured. I tried substituting report content at the point of rendering, but get the same Apache error page.</P> <P>It would seem Apache is buffering the output and only sends the output if constructed properly. Otherwise it sends nothing generated by ASP.NET and sends the error page instead.</P> <P>I don't know how Apache knows whether the ASP.NET page did a normal page rendering. If bytes are written to the response, that should be the way it is. Apache must be examining the outgoing headers. But, Apache must not be examining the start of the stream, but the entire stream, since Apache let the stream pass even if normal page rendering was at the end.</P> <P>To resolve this I need to know exactly what Apache needs to see in the stream to approve it. I can also cancel normal page rendering, to leave the report, only. Maybe Apache doesn't allow the kind of stream I'm trying to write. Is there a validation feature I can turn off?<BR> <BR> -- <BR> dgm <BR> </P></BLOCKQUOTE></HTML> <BR> |