Note that there are some explanatory texts on larger screens.

plurals
  1. POResponse.Redirect to Class that inherits from UI.Page?
    primarykey
    data
    text
    <p>everyone, thank for your time.</p> <p>Well this my problem (well it's not a probleam at all), it is possible to have a class that inherits from ui.page and then instance an object of that class and do a redirect to it ?</p> <p>Something like this:</p> <pre><code>Public sub myMethod() Dim myPage as new myClassThatInheritsFromUIPage() Response.redirect(myPage) 'Here is one of my "no-idea" line end sub </code></pre> <p>I do this in my webForm (and that what I want to do in a class that inherits from ui.page):</p> <pre><code>Response.BufferOutput = True Response.ClearContent() Response.ClearHeaders() ostream=crReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat) Response.AppendHeader("Cache-Control", "force-download") Response.AppendHeader("Content-disposition","attachment;filename=ReportAsPDF.pdf") Response.ContentType = "application/pdf" Response.BinaryWrite(ostream.ToArray()) Response.Flush() HttpContext.Current.ApplicationInstance.CompleteRequest() </code></pre> <p>What I want to do is perfectly possible with a normal WebForm, but my webForm doesn't render nothing at all (at least as (x)html so, that's because I would like to know if what I'm asking is possible to achieve.</p> <p>Thank you everyone.</p> <p>Well at the end I just add <strong>"HttpContext.Current."</strong> to all the lines that include a "response" attribute, so now I have just a class that NOT inherits from "UI.Page" and just call the method that clear the buffer (a custom method), add the headers (to force the download,set the mime type and filename) and flush the response by itself and get the effect/use I want it.</p> <p>In order to access to the Session vars just add "HttpContext.Current." and it works, I don't know how secure or if is a good way,but appears to work well.</p> <p>So the code now looks something like this:</p> <pre><code>Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Imports CrystalDecisions.ReportSource Namespace foo Public Class requestReport 'just to instance the object' Public Sub New() End Sub Public Sub downloadReport() 'do all the stuff to connect and load the report' HttpContext.Current.Response.BufferOutput = True HttpContext.Current.Response.ClearContent() HttpContext.Current.Response.ClearHeaders() ostream=crReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat) HttpContext.Current.Response.AppendHeader("Cache-Control", "force-download") HttpContext.Current.Response.AppendHeader("Content-disposition","attachment;filename=ReportAsPDF.pdf") HttpContext.Current.Response.ContentType = "application/pdf" HttpContext.Current.Response.BinaryWrite(ostream.ToArray()) HttpContext.Current.Response.Flush() HttpContext.Current.ApplicationInstance.CompleteRequest() End Sub End Class End Namespace </code></pre> <p>And from a command for example do this:</p> <pre><code>dim myReport as new foo.requestReport() myReport.downloadReport() </code></pre> <p>Of course now you can add more attributes or method if you need it.</p> <p>So now I don't even <strong>don't</strong> use Response.redirect() or inherits from "UI.Page", just a class that "change" the "current response" and "flush" the content created on fly with the crystal report, I think I was kind of totally lost but your answers really help me, especially what <strong>Tejs</strong> says, what is almost the same or the same what I just did. Thank you.</p> <p><strong>UPDATE:</strong> By the way, I just realize that the ReportDocument class has this method: <strong>ExportToHttpResponse</strong> that let us flush the Crystal Report to the browser as PDF/XSL etc forcing (or not) the download of the file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload