OUR application does not open new windows. and Users are also stupid enough to not work in multiple windows and we display ONE report at a time. So We are killing the other reports Binarys from session. Code is Below.
try
{
Session["int" + j++.ToString()] = DateTime.Now.ToString();
reportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
reportViewer1.LocalReport.EnableHyperlinks = true;
reportViewer1.LocalReport.ReportPath = "C:\\softwares\\abk.rdlc";
ReportDataSource rds = new ReportDataSource(@"abktest", Dataget());
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.Visible = true;
reportViewer1.EnableViewState = true;
List<string> lts = new List<string>();
lts.Clear();
if (Session.Count > 0)
{
foreach (string i in Session.Keys)
{
if (Session[i].GetType().FullName == "Microsoft.Reporting.WebForms.ReportHierarchy")
{
lts.Add(i);
//Session.Remove(i);
}
}
}
foreach (string s in lts)
{
Session.Remove(s);
}
for (int f = 0; f < j; f++)
{
Response.Write("current other session variables are : " + Session["int" + f.ToString()].ToString());
}
}
catch(Exception eEx)
{
Response.Write(eEx.Message + eEx.ToString());
}
We are Now thinking of creating a session Pool of reportviewer report sessions. we will keep Say 10 Report session only and kill older ones if number of report session goes beyond 10. thereby session state will not get exhausted and this error will not come.
BELOW IS CODE TO DO IT IN MUCH MORE ELEGENT WAY
private static bool INIT = false;
private static int m_AllocCount;
public const string SESSION_REPORT_KEYS = "SessionReportKeys";
public const string REPORT_SESSION_INFO = "Microsoft.Reporting.WebForms.ReportHierarchy";
Queue<string> QSessionReportKey;
/// <summary>
/// Property to USE the Alloc Count variable
/// </summary>
public static int AllocCount
{
get {
if (!INIT)
LoadConfiguration();
return m_AllocCount;
}
}
/// <summary>
/// Report session allocation count depending upon server configuartion bigger the server allocation count is More
/// read from web configuration file
/// </summary>
private static void LoadConfiguration()
{
m_AllocCount = Convert.ToInt32(ConfigurationManager.AppSettings["AllocCount"]);
INIT = true;
}
private void ConfigureReportSession()
{
//begin the session if it does not exists
if (Session[SESSION_REPORT_KEYS] != null)
{
QSessionReportKey = (Queue<string>)Session[SESSION_REPORT_KEYS];
}
else
{
QSessionReportKey = new Queue<string>();
Session[SESSION_REPORT_KEYS] = QSessionReportKey;
}
//find all the session keys for reportViewer in session variable by applying loop
IEnumerable<string> SessionReportKeys = from sKeys in Session.Keys.Cast<string>()
where Session[sKeys].GetType().FullName == REPORT_SESSION_INFO
select sKeys;
//if the keys Do Not exists in Session Add it to the session Queue
if (SessionReportKeys != null && SessionReportKeys.Count() > 0)
{
SessionReportKeys.ToList<string>().ForEach(keys =>
{
if(!QSessionReportKey.Contains(keys))
{
QSessionReportKey.Enqueue(keys);
}
});
}
//If Queue has exceeded the valid limit delete the variables
if (QSessionReportKey != null && QSessionReportKey.Count > AllocCount)
{
for (int i = 0; i < AllocCount - QSessionReportKey.Count; i++)
{
string sRemoveSession = QSessionReportKey.Dequeue();
Session.Remove(sRemoveSession);
}
}
//Reinsert the diction of session keys
Session.Remove(SESSION_REPORT_KEYS);
Session[SESSION_REPORT_KEYS] = QSessionReportKey;
}
WE have exactly Pointed the issue related to report viewers controls its due to Partial page postback. in case of complete page post back the report viewer session is cleared. But in case of Update panel, IFRAMES and master pages Due to complete rendering
does not occure. this error comes. For users using vs 2008+ then they can start using Reportviewer 10 because it has this issue resolved.
abksharma
Member
22 Points
13 Posts
Re: Good news for those of you who get "Unable to make the session state request to the session s...
Jul 28, 2011 12:20 PM|LINK
OUR application does not open new windows. and Users are also stupid enough to not work in multiple windows and we display ONE report at a time. So We are killing the other reports Binarys from session. Code is Below.
try { Session["int" + j++.ToString()] = DateTime.Now.ToString(); reportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; reportViewer1.LocalReport.EnableHyperlinks = true; reportViewer1.LocalReport.ReportPath = "C:\\softwares\\abk.rdlc"; ReportDataSource rds = new ReportDataSource(@"abktest", Dataget()); reportViewer1.LocalReport.DataSources.Add(rds); reportViewer1.Visible = true; reportViewer1.EnableViewState = true; List<string> lts = new List<string>(); lts.Clear(); if (Session.Count > 0) { foreach (string i in Session.Keys) { if (Session[i].GetType().FullName == "Microsoft.Reporting.WebForms.ReportHierarchy") { lts.Add(i); //Session.Remove(i); } } } foreach (string s in lts) { Session.Remove(s); } for (int f = 0; f < j; f++) { Response.Write("current other session variables are : " + Session["int" + f.ToString()].ToString()); } } catch(Exception eEx) { Response.Write(eEx.Message + eEx.ToString()); }abksharma
Member
22 Points
13 Posts
Re: Good news for those of you who get "Unable to make the session state request to the session s...
Jul 29, 2011 06:32 AM|LINK
We are Now thinking of creating a session Pool of reportviewer report sessions. we will keep Say 10 Report session only and kill older ones if number of report session goes beyond 10. thereby session state will not get exhausted and this error will not come.
BELOW IS CODE TO DO IT IN MUCH MORE ELEGENT WAY
private static bool INIT = false; private static int m_AllocCount; public const string SESSION_REPORT_KEYS = "SessionReportKeys"; public const string REPORT_SESSION_INFO = "Microsoft.Reporting.WebForms.ReportHierarchy"; Queue<string> QSessionReportKey; /// <summary> /// Property to USE the Alloc Count variable /// </summary> public static int AllocCount { get { if (!INIT) LoadConfiguration(); return m_AllocCount; } } /// <summary> /// Report session allocation count depending upon server configuartion bigger the server allocation count is More /// read from web configuration file /// </summary> private static void LoadConfiguration() { m_AllocCount = Convert.ToInt32(ConfigurationManager.AppSettings["AllocCount"]); INIT = true; } private void ConfigureReportSession() { //begin the session if it does not exists if (Session[SESSION_REPORT_KEYS] != null) { QSessionReportKey = (Queue<string>)Session[SESSION_REPORT_KEYS]; } else { QSessionReportKey = new Queue<string>(); Session[SESSION_REPORT_KEYS] = QSessionReportKey; } //find all the session keys for reportViewer in session variable by applying loop IEnumerable<string> SessionReportKeys = from sKeys in Session.Keys.Cast<string>() where Session[sKeys].GetType().FullName == REPORT_SESSION_INFO select sKeys; //if the keys Do Not exists in Session Add it to the session Queue if (SessionReportKeys != null && SessionReportKeys.Count() > 0) { SessionReportKeys.ToList<string>().ForEach(keys => { if(!QSessionReportKey.Contains(keys)) { QSessionReportKey.Enqueue(keys); } }); } //If Queue has exceeded the valid limit delete the variables if (QSessionReportKey != null && QSessionReportKey.Count > AllocCount) { for (int i = 0; i < AllocCount - QSessionReportKey.Count; i++) { string sRemoveSession = QSessionReportKey.Dequeue(); Session.Remove(sRemoveSession); } } //Reinsert the diction of session keys Session.Remove(SESSION_REPORT_KEYS); Session[SESSION_REPORT_KEYS] = QSessionReportKey; }abksharma
Member
22 Points
13 Posts
Re: Good news for those of you who get "Unable to make the session state request to the session s...
Aug 02, 2011 08:45 AM|LINK
WE have exactly Pointed the issue related to report viewers controls its due to Partial page postback. in case of complete page post back the report viewer session is cleared. But in case of Update panel, IFRAMES and master pages Due to complete rendering does not occure. this error comes. For users using vs 2008+ then they can start using Reportviewer 10 because it has this issue resolved.