Reputation: 3
This is my .Net 2 ASP.Net code that used to work when hosted on Win 2000 and IIS3.
'In Page_Load, if it's NOT a PostBack then remove the cached report object so the that code later is forced to rebuild it.
Under Win2000 and IIS3 when I clicked a link to load the Page fresh, in Page_Load it would call Session.Remove("ReportObject"), then in FillRptParams realise the Session("ReportObject") is Nothing and reload it.
I initially put all the Session code in to make sure that between Crystal Report page requests it wouldn't keep going to the DB, it would just pull the ReportObject from the session variable display the next page.
Now I've switched to Win 2003 and IIS6 I ALWAYS get the SAME report served up, even when clicking on the link as I used to which essentially causes IsPostBack to be false and remove the Session object.
I'm hoping it might some settings under IIS6 that can make it behave as it used to.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Session.Remove("ReportObject")
End If
End Sub
Sub FillRptParams(ByVal snavcode As String, Optional ByVal CrystalOrPDForEXCEL As String = "")
If Not Session("ReportObject") Is Nothing Then
bReportCached = True
Else
bReportCached = False
End If
oSqlCmd = New SqlCommand
If bReportCached Then
orpt = Session("ReportObject")
Else
orpt = New rptUsageSummaryNew
oSqlCmd.CommandText = "HOSP_RPT_UsageAllSummary"
oDS = oDataAccess.GetReportDataSet(Session("Group"), oSqlCmd)
orpt.SetDataSource(oDS)
'Cache the report object so we don't have to load it again next time
Session.Remove("ReportObject")
Session.Add("ReportObject", orpt)
End If
End Sub
Upvotes: 0
Views: 345
Reputation: 449
Move your code in the Page_init event, not in the page_load. And suppress your "if postback code" when you have moved it .
Upvotes: 0