State Management :: Accessing Session Arraylist

Jul 13, 2010

I am using a Session Arraylist to hold information about an online user. However, I am having troubel accessing the data. The error seems to be in the last bit because I can access one value of sample data just not print out a number of values. I have an class penalyPoint that has the following constructor:

public PenaltyPoint(string penaltyCode1, string penaltyDate1, string PenaltyPointsAwarded1, string penaltyBan1)

Then in a button response I have the following response which holds the data in a session arraylist variable as the user can enter a number of these objects. I will put a capacity limit on the arraylist later on.

//Assign the data in the form to a PenaltyPoint Object
PenaltyPoint penPoint = new PenaltyPoint(ddlPen1Code.SelectedValue, txtPenDate.Text, txtPen1Points.Text, txtPen1Ban.Text);
//The current driver number has to be set before this page is called
//Temp
int currentDriver = 0;
//int currentDriver = (int)(Session["currentDriverNum"]);
//create an arraylist to be used for transferring arraylist to session
ArrayList penPointsDrive0Array = new ArrayList();
if (currentDriver == 0)
{
//if the session is equal to null then nothing has to be returned from session
if (Session["penPointsArrayListDrive0"] == null)
{
penPointsDrive0Array.Add(penPoint);
Session["penPointsArrayListDrive0"] = penPointsDrive0Array;
Response.Redirect("PenaltyPoints.aspx");
}
else
{
penPointsDrive0Array = (ArrayList)Session["penPointsArrayListDrive0"];
penPointsDrive0Array.Add(penPoint);
Session["penPointsArrayListDrive0"] = penPointsDrive0Array;
Response.Redirect("PenaltyPoints.aspx");
}
}

Then I try to access the data in the arraylist but I getting nothing printing out. I am just trying to test the data at the minute. I am not that use to arraylist so this might be the problem.

public partial class TestPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ArrayList answer = new ArrayList();
ArrayList driver1 = (ArrayList)Session["penPointsArrayListDrive0"];
PenaltyPoint ps = new PenaltyPoint();
string output;
for (int i = 0; i < driver1.Count; i++)
{
ps = (PenaltyPoint)driver1[i];
string answertemp = ps.getPenaltyCode();
output = answertemp;
}
}
}

I can't get the final part to collect all the values into a string it keeps on coming up with errors.

View 2 Replies


Similar Messages:

State Management :: Store An ArrayList Into A Session Variable?

Apr 23, 2010

I'm looking store an ArrayList into a session variable, but am having a few problems. Can you spot anything wrong?

public partial class _Default : System.Web.UI.Page { ArrayList score = new ArrayList(); protected void twist2(object sender, EventArgs e) { int a = 11; int c = RandomNumber(a); score.Add(c); score = (ArrayList)Session["scoreData"]; Result.Text = (c).ToString(); String Result_id = Result.Text; int total = 0; //Session["scoreData"] = score; for (int i = 0; i < score.Count; ++i) { total += (int)score[i]; } Sum.Text = (total).ToString(); String Sum_id = Sum.Text; }

View 3 Replies

State Management :: Memory Size Of Session / ArrayList?

Apr 24, 2010

I am using ASP.NET 2.0.

In my applicaion, I store some values in an ArrayList and store this Arraylist in a session variable. I want to know the size of this session variable in memory. Is there any method to do this.

View 6 Replies

State Management :: Accessing Session State In A User Control?

Sep 1, 2010

We have a web site that implements a custom SiteMapProvider using a User Control added in the master page. I need to be able to limit the sitemap nodes added depending on the logged in user, that is, certain users should not see certain sitemap nodes. Currently, the login processing code determines if users are in the certain category or role and then sets a value in session state, for example, Session["UserInRoleXXX"] = "Yes"; I tried changing the code in the user control to check the session state, but I got the following error: NullReferenceException ... Object reference not set to an instance of an object." Can session state be accessed in a user control?

View 6 Replies

State Management :: Multidimentional Arraylist / Create A Arraylist Which Will Able To Store User Info?

Jul 16, 2010

i want to create a arraylist which will able to store user info like (username,machineIP,port ) for each user in the list & retrive this data when needed . any one tell me how i can do it or any alternative way without database or xml file.

View 6 Replies

State Management :: Accessing Session With Rewritten URL

May 21, 2010

I've searched these forums, found some pretty similar problems, but haven't found solution to the following:

I'm using simple engine (IHttpModule hooks to BeginRequest) to rewrite some URL on the site and everything works perfectly as long as original URL ends with .aspx, example:

http://site/articles/Article-name.aspx rewrites to real location
http://site/DisplayArticle.aspx?name=Article%20name

Tries to use any other URL which DOES NOT end with .aspx results in that Page.Session throws an exception and Page.User is always null (Forms Authentication) Integrated Visual Studio development server works fine in any way, this is only happens when I'm trying local IIS or hoster machine.

View 3 Replies

State Management :: Accessing Variables Across Pages Within The Same Session?

Jul 12, 2010

How can I retain the value of variables that I fill from CodeBehind throughout the session? (C#). For example, I do a LINQ query from the log in "on-Click" button event. The query produces a bunch of data about the user that I want to access throughout the session on additional ASP pages. I know that I can pass a large query string but I suspect that there is a better way. Here's a specific...

from the db function I product: COS=2 (class of service). Throughout the session, I test for COS and display appropriate pages. Assume that the LINQ query is accomplished in the CodeBehind attached to the "loginButton" within the "login.aspx" page.

View 3 Replies

State Management :: Accessing A Session Variable In HTML For A Boolean Expression?

Nov 4, 2010

[code]...

How do I correctly define my boolean expression? I've been looking, but haven't found the right syntax.

View 4 Replies

State Management :: Setting Session Values In Generic Handler And Accessing Them From A Page?

Jun 10, 2010

I have a generic handler in which I fill up a Session variable. I implemented the IRequiresSessionState interface, so it shouldn't be a problem.

In a given page, I want to display that value, but it seems like the value is always empty. Is it because the session that is accessed and written to in the handler isn't the same one that is used on this page?

In the handler, I used context.Session["EID"] = "somevalue";

edit: i found out what the issue is but I do not know how to solve it. It's because I have this Java applet which reads out an eID, calls the handler to store the data, but the session used by the applet is not the same as the session used by the browser... so how could I exchange this data in a safe way?

View 1 Replies

Session State ArrayList In Shopping Cart?

May 1, 2010

I'm creating a shopping cart application and I'm having some issues with implementing a session state for my arraylist.

in my page load i declared

if (Session["Cart"] == null)
{
Session["Cart"] = new ArrayList();
}
else
{
ArrayList cart = (ArrayList)Session["Cart"];
}

to create the session if it doesn't exist yet.
then i have an event handler for a button to add items to the arraylist

protected void onClick_AddBooking(object sender, EventArgs e)
{
int ClassID = Convert.ToInt32(Request.QueryString.Get("Class_Id"));
ArrayList cart1 = new ArrayList();
cart1 = Session["Cart"];
cart1.Add(ClassID);

I'm essentially storing the class_ID then when the student confirms i'll store that to the DB and associate that ID with the Class Details.

View 1 Replies

State Management :: Error :Session State Has Created A Session Id, But Cannot Save It?

Nov 18, 2010

I read the solutioin for this error, at the following link :http://forums.asp.net/p/1046935/1576341.aspxbut I am still not clear what exactly causes the error. I have two doubts :1. Can anyone please elaborate a bit on this issue, with any example ????2. Is there any drawback of this approach ?

View 4 Replies

State Management :: Session Mode State Server - Sending Asynchronous Request

Nov 5, 2010

Customer were getting "View State Validation Error" due to worker process recycling at our production webserver and to fix that i applied machinekey and then move my Session state Mode from In Proc to State Server to retain session data and not kick out the customer to relogin. I had serialization issue with one object which has to be stored in session but when i moved it out of session i could able to resolve the issue.

But doing all these i was partly successfull in keeping the user in their session when Worker Process recycle event occurs.I was able to refresh the page or make a post back by clicking the refresh button and also able to retain the session values. But the Problem occurs when sending asynchronous request to server which we do periodically every 15 minutes from the moment the user logs in.The web page doesnot update data on website when sending asynchronous request.By Debugging I found at this particular code point it fails to make a postback which is required.

<%=GetHintFromServer%> (When there is no Worker Process recycle i t gets replaced by
WebForm_DoCallback('__Page',message,ShowHint,null,null,false) on postback) Everything works fine when there is no Worker Process Recyling but when it happens looks like sending request asynchronously using javascript fails .Remember When I make a post back by manually clicking submit button everything works fine.

SendRequest(Asynchronous)
function SendRequest(msg, isBusy, chartMsg, vesselMsg)
{
try
{
//confirm("msg"+msg+"isBusy"+isBusy+"chartMsg"+chartMsg+"VesselMsg"+vesselMsg);
_busy = isBusy;
if(chartMsg != null)
{
//confirm("chartMsg"+chartMsg);
_element.SetMessage(true, chartMsg);
}
if(vesselMsg != null)
{
confirm("chartMsg"+vesselMsg);
_element.ShowVesselLoading(true, vesselMsg);
}
_stuckWatchdog = setTimeout( "ClearPendingRequest();", 60000);
var message = msg;
var context = '';
<%=GetHintFromServer%>
}
catch(e)
{
alert( "Exception error on SendRequest(): " + e);
}
}

View 2 Replies

State Management :: Unable To Serialize The Session State In 'StateServer' And 'SQLServer' Mode

Dec 12, 2010

I am new to .net 4.0 and am using EF Model and SessionState Mode=SqlServer and I am getting this error below:

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

I checked the stack trace and its complaining about

[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("PoplarGroveModel", "tblMenuRole", "tblMenu", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(PoplarGroveDataModel.Menu), "tblRole",

[Code].....

I marked it as serializable but then it complains about System.Data.Objects.ObjectContext is not marked as serializable and hence throws the same error.

View 1 Replies

State Management :: Recreate State Session Database In SQL Server 2008?

Apr 5, 2010

Our ASP.NET App uses ASP State Session Management and has been rebuilt about 2 years ago [With .NET Framework 2.0]. We are currently in .NET framework 3.5 and have moved to SQL Server 2008 - but continue to use the same ASPState database. The State database has been upgraded to SQL Server 2008. Since then we have are seeing timouts/locks on ASPStateTempSessions table. I am wondering if we have to rebuild this database from scratch with some newer scripts?

View 2 Replies

State Management :: Asp Create New Session State Cookie Each Time On Debugging?

Jan 21, 2011

I'm using the following line of code to display the number of users currently logged on:

lblNoOfUsers.Text = Membership.GetNumberOfUsersOnline().ToString()

I'm still debugging my application so it's on the local server. As I debug and stop then debug again, eventually lblNoOfUsers.text turns to "0" instead of "1", even as I'm navigating my application. It only turns to "1" again if I log out and sign back in. It's almost as though Membership.GetNumberOfUsersOnline my login are referencing two different session states. How is this possible? Does asp.net create a new session state cookie each time I start debugging?

View 2 Replies

State Management :: Losing Session State In Global.asax File?

Feb 2, 2011

I am trying to set a session variable in the global.asax file and keep running into the problem that the Session is null.

I am running my application in VS2008 and using asp.net 3.51.

Here is my code:

1. In my web.config file I have enabled the session state and added the following line;

<sessionState
cookieless="false"
mode="InProc"
timeout="60"
></sessionState>

2. In the Session_Start procedure in the Global.asax file I set the session variable to a default value.

[Code]....

My problem seems to be that when the Application_Error procedure is executed the session state is lost.

Does anyone know why the session state isn't available in the Global.asax file.

View 9 Replies

State Management :: Session State Expiration After Application Pool Recycle?

Nov 1, 2010

All we have a global ships position tracking website which runs smoothly until IIS application pool recycles.When there is workerprocess recycling looks like session state expires as a result i loose all session data and when customer clicks refresh button he is redirected to login page.

In web.config Session state mode is set to InProc so i changed it to State Server but to my luck i have MAP object which is not serialiazable which is causing the maps from not appearing on the website.I tried adding serializable attribute to the object class but still not succesfull.Our website is accessed by our customers whose count is more than 1000.

Changing the session state mode from InProc to StateServer can really slow down the response time so
Is it good to go further fix the serailizable issues and move to state server?.

Is there any way I can retain my session data when application pool recyles?..

Stopping Application pool from recycling may not be a good idea considering health factor of web server.

View 8 Replies

State Management :: Session State Returning Null Values?

Apr 29, 2010

I have a clear button and a textbox in an aspx page. I set the session variable in this page as

String str = Textbox1.Text;

Session["TypeIds"] = str;

and I clear the sessions in a clear button event as

Session["TypeIds"]=null;.

Then when the user types some value in the textbox ,on Response.Redirect on another aspx page, the session variable returns null values.It does not retain its session state. The session state has to be maintained in the next page. Is it because this clear button event and setting explicitly to null creates this problem?

View 7 Replies

State Management :: Version 2.0 Session State Not Installed On SQL Server?

Oct 27, 2010

The fix for this error message is to run [Code]..... I have run that uptown, downtown and in my lady's chamber and it does no good, although it never complains. Are there any other possibilities?Details:
IIS Server: v5.1 running on XP. SQLServer 2005 running on a different XP box.Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618 There is an ASPState database on the server, containing only two tables: [Code].... and [Code]..... I did not use [Code].... when I ran [Code]....
.

View 2 Replies

State Management :: Session Variable Authentication State Timeout?

Dec 3, 2010

I am building a web app that is limited to one database, therefore I cannot use the ASP.NET config tool. As a quick means of getting this app online, I tried to use a simple session variable. The login page verifies the user's credentials, and if they pass, it sets the session variable to a certain value. All other pages check in the page_load event whether or not the session variable is equal to that value. The problem is that once being logged in for a short while and sending and recieving some data, the session variable resets, and I'm returned to the login page to repeat the process. Here's the basic code from my webforms:

[code]....

Is there some setting I need to change in the web.config file to adjust the cookie timeout or is that only for the config tool authentication methods?

View 5 Replies

State Management :: When To Choose Out Proc Session State Mode

Feb 13, 2011

Just wanted to know in which type of web applications we can use or its good to use the out proc (SQL Server, State Server) session mode?

View 4 Replies

State Management :: Deleting Folder And Session State Mode?

Mar 16, 2011

I write a simple web site in asp.net. In one page i want to delete a folder of web root. When i delete it folder, the all session in project is changed to null. I write a post in this forum. Here is the adress of it post: ([URL]) Some pepole answer me to change the session state mode to StateServer. In default the session state mode is Inproc, and i changed the session state mode to stateServer.but when i changed the session to stateserver this error is appear in application eventlog after two day and my web site dont working in iis. This error is like this:

Event Type:
Warning
Event Source:
ASP.NET 2.0.50727.0
Event Category:
Web Event
Event ID:
1310
Date:
3/12/2011
Time:
1:27:55 PM
User:
N/A
Computer:
WIN2003-00A346F
Description:
Event code: 3009
Event message: Unable to make the session state request to the session state server. Details: last phase='Sending request to the state
server', error code=0x80072749, size of outgoing data=0
Event time: 3/12/2011 1:27:55 PM
Event time (UTC): 3/12/2011 8:57:55 AM
Event ID: a5c8bfd16f74429e820989e8ce8082d0
Event sequence: 10
Event occurrence: 1
Event detail code: 50016
Application information:
Application domain: /LM/W3SVC/1547208020/Root-1-129443938731955000
Trust level: Full
Application Virtual Path: /
Application Path: C:InetpubwwwrootClishareClishare
Machine name: WIN2003-00A346F
Process information:
Process ID: 1276
Process name: aspnet_wp.exe
Account name: WIN2003-00A346FASPNET
Exception information:
Exception type: HttpException

Exception message: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesaspnet_stateParametersAllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.

Request information:
Request URL: [URL]
Request path: /main/home.aspx
User host address: 64.79.69.155
User:
Is authenticated: False
Authentication Type:
Thread account name: WIN2003-00A346FASPNET
Thread information:
Thread ID: 1
Thread account name: WIN2003-00A346FASPNET
Is impersonating: False

Stack trace: Custom event details: For more information, see Help and Support Center at [URL]. When i reset ASP.NET State service, the problem is fixed, but after one or two days, this problem apears again. What's the problem and how can i fix it? And how can i delete a folder in asp.net without the session is lost?

View 1 Replies

State Management :: Unable To Make The Session State Request

Apr 21, 2010

Our Web Server rebooted due to power failure. Now ASP.Net State service would not start logging the following error on the server:

Unable to make the Session State Request to the session state server. Last known phase=Sending request to the state server

how to bring back the ASP.Net State service.

View 2 Replies

State Management :: Session State Information Is Invalid And Corrupted

Jan 13, 2011

I am getting this error "The session state information is invalid and might be corrupted " as i hve checked all my session variable initialized with some default value and the existing code works fine in version 1.1 but on conversion it is giving specified error. The error comes when i simply click on a link to redirect to some other page.

View 5 Replies

State Management :: Session State/ Setting Start And End Timings?

Oct 30, 2010

I created a form where I put some radio buttons. When User select one of them depending upon the option it will start his / her time counter. StartTime and EndTime and I am couting total time he/she takes. Till here it is OK. But what I want when user clicks on Logout, then he/she will logged out (Temporary). and after the some time when he / she will again login..... here, I want to set his / her EndTiming. I don't understand how to maintain this state?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved