473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Weird session state problem, maybe?

I have an ASP.NET 2.0 application. It is pretty basic. What it does is
shows a gridview of data from a stored procedure. The user can also select a
date filter. The problem is that sometimes an error is thrown about getting
the data. If I go in and make a change to the .cs file, the application runs
fine. The change I make is like insert a space somewhere just to make the
file recompile and it works again. What causes this? It sounds like the
session state is persisting or something. I have posted the code below. Any
help would be appreciated. Thanks.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Principal;
using System.Text;
using NsiMsCrmWebService;
using System.Threading;
using System.Collections;

public partial class _Default : System.Web.UI.Page
{
public static DataSet myDataSet = new DataSet();
double dblGroupSumOppTotal = 0, dblGroupSumExpected = 0,
dblGroupSumForecast = 0, dblReportSum = 0, dblGroupSumDirForecast = 0;
NsiMsCrmWebService.NsiMsCrmWebService myWebService = new
NsiMsCrmWebService.NsiMsCrmWebService();
static string strTerritory = "", strStartDate = "", strEndDate = "",
strSort = "", strSortOrder = "";

#region Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
strStartDate = "";
strEndDate = "";

pnlReport.Visible = false;
pnlSelectTerritory.Visible = false;
pnlSearch.Visible = false;
lbnFilter.Visible = false;

//First we need to see if they are authorized to use this tool
WindowsPrincipal p = Thread.CurrentPrincipal as WindowsPrincipal;
int idx = p.Identity.Name.IndexOf('\\');
string strUserName = p.Identity.Name.Substring(idx + 1);

//Now that we have the username, we need to check to see if they
are authorized
//and display the right territory
switch (strUserName.ToLower())
{
//Eastern Rep
case "chris.montanaro":
//Build the list item
ddlTerritory.Items.Add(new ListItem("Canada", "Canada"));
ddlTerritory.Items.Add(new ListItem("Eastern",
"Eastern"));
pnlSelectTerritory.Visible = true;
break;

//Western Rep
case "steve.dupree":
//Build the list item
ddlTerritory.Items.Add(new ListItem("Canada", "Canada"));
ddlTerritory.Items.Add(new ListItem("Western",
"Western"));
pnlSelectTerritory.Visible = true;
break;

//Admins
case "dean.goodermote":
case "william.waller":
case "bob.davis":
case "will.anderson":
case "dan.jones":
case "donna.colonna":
case "vwright":
case "vincent.wright":
case "anna.combs":
case "melinda.denney":
ddlTerritory.Items.Add(new ListItem("Canada", "Canada"));
ddlTerritory.Items.Add(new ListItem("Eastern",
"Eastern"));
ddlTerritory.Items.Add(new ListItem("Western",
"Western"));
ddlTerritory.Items.Add(new ListItem("International",
"International"));
pnlSelectTerritory.Visible = true;
break;

//No Access
default:
lblStatus.Text = "You do not have access to this
application.";
break;
}
}
}
#endregion

#region BindData()
void BindData()
{
if (strTerritory != "")
{
myDataSet = myWebService.rdfGetData(strTerritory, strStartDate,
strEndDate);

myDataSet.Tables[0].TableName = "Data";
myDataSet.Tables.Add("ESM");

string[] distinct = { "ESM" };

myDataSet.Tables["ESM"].Clear();

myDataSet.Tables["ESM"].Merge(myDataSet.Tables["Data"].DefaultView.ToTable(true, distinct));
myDataSet.Relations.Add(new DataRelation("ESMGroup",
myDataSet.Tables["ESM"].Columns["ESM"],
myDataSet.Tables["Data"].Columns["ESM"]));

myRepeater.DataSource = myDataSet.Tables["ESM"];
myRepeater.DataBind();

lbnFilter.Visible = true;
}
}
#endregion

#region myRepeater_ItemDataBound
protected void myRepeater_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
Repeater rpt = (Repeater)e.Item.FindControl("myRepeater2");
if (rpt != null)
{
DataView myDataView =
((DataRowView)e.Item.DataItem).CreateChildView("ES MGroup");

if (! string.IsNullOrEmpty(strSort))
{
myDataView.Sort = strSort + " " + strSortOrder;
}

rpt.DataSource = myDataView;
rpt.DataBind();
}
}
}
#endregion

#region myRepeater2_ItemDataBound
protected void myRepeater2_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
string strEstimatedValue = DataBinder.Eval(e.Item.DataItem,
"estimatedValue").ToString();
bool bEsmForecast = (bool)DataBinder.Eval(e.Item.DataItem,
"CFBForecast");
bool bDirForecast = (bool)DataBinder.Eval(e.Item.DataItem,
"CFBDirectorForecast");

if (strEstimatedValue != "")
{
dblGroupSumExpected +=
Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "estimatedValue"));
}

if (bEsmForecast)
{
dblGroupSumForecast +=
Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "estimatedValue"));
}

if (bDirForecast)
{
CheckBox myCheckBox =
(CheckBox)e.Item.FindControl("chkForecast");
myCheckBox.Checked = true;
dblGroupSumDirForecast +=
Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "estimatedValue"));
}

dblGroupSumOppTotal += 1;

//We need to set the image for the ESM forecast
if (bEsmForecast)
{
HtmlTableCell myTableCell =
(HtmlTableCell)e.Item.FindControl("tdEsmForcast");
myTableCell.InnerHtml = "<strong>X</strong>";
}
}
else
{
if (e.Item.ItemType == ListItemType.Footer)
{
//Display the Total Expected Revenue (ESM) in the group footer
Label groupSumExpected =
(Label)e.Item.FindControl("lblGroupSumExpected");
groupSumExpected.Text = dblGroupSumExpected.ToString("c");
dblGroupSumExpected = 0;

//Display the Total Forecasted Revenue (ESM) in the group
footer
Label groupGroupSumForecast =
(Label)e.Item.FindControl("lblGroupSumForecast");
groupGroupSumForecast.Text =
dblGroupSumForecast.ToString("c");
dblGroupSumForecast = 0;

//Display the Total Opportunities in the group footer
Label groupSumOppTotal =
(Label)e.Item.FindControl("lblGroupSumOppTotal");
groupSumOppTotal.Text = dblGroupSumOppTotal.ToString();
dblGroupSumOppTotal = 0;

//Display the Total Opportunities in the group footer
Label groupGroupSumDirForecast =
(Label)e.Item.FindControl("lblGroupSumDirForecast" );
groupGroupSumDirForecast.Text =
dblGroupSumDirForecast.ToString("c");
dblReportSum += dblGroupSumDirForecast;
dblGroupSumDirForecast = 0;
}
}

lblReportSum.Text = strTerritory + " - " + dblReportSum.ToString("c");
lblForecastTotal.Text = dblReportSum.ToString("c");
}
#endregion

#region btnUpdate_Click
protected void btnUpdate_Click(object sender, EventArgs e)
{

DataSet dsUpdateForecast = new DataSet();
DataTable dtUpdateForecast = new DataTable();
dtUpdateForecast.Columns.Add("opportunityid");
dtUpdateForecast.Columns.Add("directorsforecast");

myDataSet.Tables["Data"].DefaultView.Sort = "opportunityid,
CFBDirectorForecast";

for (int i = 0; i < myRepeater.Items.Count; i++)
{
Repeater detailRepeater =
(Repeater)myRepeater.Items[i].FindControl("myRepeater2");

for (int j = 0; j < detailRepeater.Items.Count; j++)
{
CheckBox directorForecast =
(CheckBox)detailRepeater.Items[j].FindControl("chkForecast");
Literal rdfGuidLiteral =
(Literal)detailRepeater.Items[j].FindControl("rdfGuid");

object[] objVal = new object[2];
objVal[0] = rdfGuidLiteral.Text;
objVal[1] = directorForecast.Checked.ToString();

int iFound =
myDataSet.Tables["Data"].DefaultView.Find(objVal);

if (iFound < 0)
{
DataRow myDataRow = dtUpdateForecast.NewRow();
myDataRow["opportunityid"] = rdfGuidLiteral.Text;
myDataRow["directorsforecast"] =
directorForecast.Checked.ToString();
dtUpdateForecast.Rows.Add(myDataRow);
}
}
}

dsUpdateForecast.Tables.Add(dtUpdateForecast);

myWebService.Timeout = 600000;
bool bUpdate = myWebService.rdfSetForecast(dsUpdateForecast);

if (bUpdate)
{
lblStatus.Text = "The Report was successfully updated";
}
else
{
lblStatus.Text = "There was an error updating the report.";
}

BindData();

}
#endregion

#region btnSubmitTerritory_Click
protected void btnSubmitTerritory_Click(object sender, EventArgs e)
{
strTerritory = ddlTerritory.SelectedValue;
pnlSelectTerritory.Visible = false;
pnlReport.Visible = true;
strStartDate = "";
strEndDate = "";
BindData();
}
#endregion

#region lbnFilter_Click
protected void lbnFilter_Click(object sender, EventArgs e)
{
pnlReport.Visible = false;
pnlSearch.Visible = true;
lblStatus.Text = "";
}
#endregion

#region btnSearchSubmit_Click
protected void btnSearchSubmit_Click(object sender, EventArgs e)
{
strStartDate = txtStartDate.Text;
strEndDate = txtEndDate.Text;

pnlReport.Visible = true;
pnlSearch.Visible = false;

BindData();
}
#endregion

#region btnSearchCancel_Click
protected void btnSearchCancel_Click(object sender, EventArgs e)
{
pnlReport.Visible = true;
BindData();
}
#endregion

#region Sort_Click
protected void Sort_Click(object sender, EventArgs e)
{
LinkButton myLinkButton = (LinkButton)sender;

switch (myLinkButton.ID)
{
case "OpportunitySort":
strSort = "accountname";
break;

case "ExpectedRevenueSort":
strSort = "estimatedValue";
break;

case "ExpectedCloseDateSort":
strSort = "estimatedClosedate";
break;

case "EsmForecastSort":
strSort = "CFBForecast";
break;

case "DirectorsForecastSort":
strSort = "CFBDirectorForecast";
break;

default:
break;
}

if (strSortOrder == "ASC")
{
strSortOrder = "DESC";
}
else
{
strSortOrder = "ASC";
}

BindData();
}
#endregion
}
--
Vincent Wright
Apr 25 '07 #1
3 1527
vincentw56 wrote:
I have an ASP.NET 2.0 application. It is pretty basic. What it does
is
shows a gridview of data from a stored procedure. The user can also
select a
date filter. The problem is that sometimes an error is thrown about
getting
the data. If I go in and make a change to the .cs file, the
application runs
fine. The change I make is like insert a space somewhere just to
make the
file recompile and it works again. What causes this? It sounds like
the
session state is persisting or something. I have posted the code
below. Any
help would be appreciated. Thanks.
In IIS Manager, get the properties for the Application Pool you're using.
Under the performance tab, is the Web garden property set to more than 1?

Andrew
Apr 25 '07 #2
It is set to 1.
--
Vincent Wright
"Andrew Morton" wrote:
vincentw56 wrote:
I have an ASP.NET 2.0 application. It is pretty basic. What it does
is
shows a gridview of data from a stored procedure. The user can also
select a
date filter. The problem is that sometimes an error is thrown about
getting
the data. If I go in and make a change to the .cs file, the
application runs
fine. The change I make is like insert a space somewhere just to
make the
file recompile and it works again. What causes this? It sounds like
the
session state is persisting or something. I have posted the code
below. Any
help would be appreciated. Thanks.

In IIS Manager, get the properties for the Application Pool you're using.
Under the performance tab, is the Web garden property set to more than 1?

Andrew
Apr 25 '07 #3
>In IIS Manager, get the properties for the Application Pool you're
>using. Under the performance tab, is the Web garden property set to
more than 1?
vincentw56 wrote:
It is set to 1.
Oh well... when I've made the session state go wrong it was because I
changed that setting.

You forgot to post the exact error message in your OP.

Andrew
Apr 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
3
by: Martin | last post by:
Hi all As my posting title suggests I'm having problems using InProc Session state in my ASP .NET app. I wrote a site for a friend which uses ADO .NET to keep track of a simple...
8
by: Anthony P. Mancini | last post by:
I'm working on a proof of concept that will ultimately be deployed on a load balancer. For the sake of a preliminary demonstration I created a C# object and marked it's attributes as Public...
4
by: John Allberg | last post by:
Hi! We have a problem which is correlated to web farms and session handling and are thinking of what solution to choose. Our setup is with a web farm, one ldap server and a database cluster. ...
2
by: Tomas Martinez | last post by:
Hi, Well, my problem is so simple as it says in the subjet but very frustrating also. I have a project and it is losing the session variables with each postback, so I downloaded from the web a...
7
by: Erik | last post by:
I have an application that uses sessions variables a lot but one I publish the application on the prod server these variables are lost. The application is written i c# 2.0 and I've set the...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
2
by: DC | last post by:
Hi, we are using ASP.Net 1.1 on eight servers with one session state server (the windows 2003 service). Too often we are getting the exception "Unable to make the session state request to the...
3
by: SevDer | last post by:
Hi All, I am recently experiencing a weird problem. I don't know what exactly is the cause of the problem but here is my scenario and symptoms. First of all here is my architecture 1. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.