I am developing a website where the user enters data into a form. The user can then go back and edit the data that is saved in a session variable and then the data is resaved in that session variable in an arraylist. However, for some reason although the data is resaving it is resaving the original data. I know this as I tested the code without the remove request to the arraylist and the original data was just added to the bottom of the array. I wondering if anyone would know why the new data is not saving. Any help would be really appreciated as I have only been programming for a few of months. Some of the code is below.//The gridview shown on a page which lists the objects saved by the user which he/she can edit and edit is the only one I am concerned with here as the other works
Lets say I am doing a shoping cart. I authenticate the user with a session variable.For example:
If(Request.IsAuthenticated) // Here I want to add to the shoping cart. // Can I do the following Session["Cart"] = "Washing Machine"; Now will this Session["Cart"] value which is washing machine here be unique to diff customers?
I have inherited a very large ASP.NET app that needs to be modified to use a State Server instead of in-proc sessions. I need to track down all classes used in session throughout the app and then determine if they can be serialized. Are there any tools that can be used to analyze the code to determine the classes used in session?
I set a session object at one juncture in my code:
Session("my_name") = "Dave"
Later in my code I give the user a chance to update this object:
Session("my_name") = TextBox1.Text
I reload my page and display a little hello statement like this:
Label1.Text = "Hello" & CStr(Session("my_name"))
The result is: "Hello Dave" no matter what I change Session("my_name") too.
EDIT: Here is the a full code-behind I wrote up to demonstrated:
Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.ExpiresAbsolute = DateTime.Now.AddMonths(-1) If Page.IsPostBack = False Then Session("my_name") = "Dave" End If Label1.Text = CStr(Session("my_name")) End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Session("my_name") = TextBox1.Text End Sub
In the project I'm working on I have got a list List<Item> with objects that Is saved in a session. Session.Add("SessionName", List);
In the Controller I build a viewModel with the data from this session
[Code]....
and in my View I loop trough the list of Items and make a form for all of them to be able to remove the item.
[Code]....
When the post from the submit button is handeld the item is removed from the array and post back exactly the same viewModel (with 1 item less in the itemList).
return View("view.ascx", viewModel);
When the post is handled and the view has reloaded the value's of the html.Hidden and Html.Textbox are the value's of the removed item. The value of the html.Encode is the correct value. When i reload the page the correct values are in the fields. Both times i build the viewModel the exact same way.
I am getting a serialization error trying to use Session State Server instead of InProd. However, I can't figure out what is causing the error in session. I was given some code to add to the page to loop through the session object and figure out if each item in it is serializable. My problem is I don't know where to place the code in the ASP.NET page. In tracing through the code, the error just appears after steping through objects outside of the page and not when setting session. There must be some place that I can place the code on the page that is after all session objects are set but before the page will error. Where would that be?
I know that Session is for a single user , and application is for multi user purpose.The Data in the application object is shared. Right? Then how can access the application data from an another client.
If I have not activity in browser for about 10 mins, shouldn't the Session object be removed. But after 10 mins I can still access the Session variable. Am I missing something here?
EDIT:
If I access a session variable after 10 mins as shown below shouldn't I get NULL
var myObj = Session["MyKey"] as MyClass; mObj is not NULL after 10 mins.
So, I am working on a demo web dashboard. Previously, I had been using Session to store settings about the dashboard, but I would like to move it to a more persistent means of saving settings.It seems to me that using cookies would be my best bet. I'm not entirely positive I have the time to work everything out for writing to/from a database properly.That being said, I might be in over my head on some assumptions I had made about the similarities between Session and Cookies. Currently, I have some code like this:
public Dictionary<string, RadPageViewSetting> PageViewStates { get
I'm trying to convert a game I made (WindowsFormApplication) to an ASP.NET page.
My Problem is that I have a lot "private" variables in my WindowFormApplication and those variables are important for the game. But when after I Declare all my variables (in my Page_Load), they turn null no matter what I do(click a button, refresh the page).
Is there anyway to save my variables between buttons (other than Session, because I'd have to create like 6 more sessions)
I am reviewing some web code and I am not exactly sure how ASP.net session state works. If a User object is saved to the session state during login, and User.FirstName and User.LastName is set. If other web pages retrieve the user object from the session and set the FirstName to something else is that persisted on other web pages? Or, do you need to re-add the user object back to the session once it has been modified?
I need to save data in a datatable on a web page where the user is adding items to order. I know how to create a datatable and add data to it. And I will be binding it to a gridview control. But I do not want to loose the data when the page does a postback. Do I need to save it to a session variable for this? Or will the data stay in the datatable?
I found this code posted online. Is this how I would save it to a session variable and then load it anytime?
Code: Dim dt As New DataTable() Session("MyDataTable") = dt ' To retrieve it from session Dim dt As DataTable = DirectCast(Session("MyDataTable"), DataTable)
I've just upgraded my development machine from XP SP3 (IIS5.1) to Win7 x64 (IIS7.5)
Since doing this, my app has started to behave differently. Within it I store users' preferences/access levels using an instance of a class that I store within the Session object. This class is shown:
[Code]....
My requirement is that on each page request (other than the login page), the application should check that the Session object exists. The page data is therefore shown based on the values within the session object (e.g. which customer account they are using etc)...Previously on IIS5.1 if I was logged into the app, but made some changes to a file within App_Code, or Web.Config for example, when I then continued to use the app, I would get kicked out to the login page straight away. This is the intended behaviour. Now however, on IIS7.5, the app continues to provide access to the pages, but debugging shows that the session value has had all of its values set to 0 (zero). Therefore, the pages continue to load but the data shown is corrupted because the app no longer displays it accurately. Here is the code I use which (on IIS5.1) caught this occurence. Can anyone offer any advice on just what's now happening
I've noticed that once I've instantiated 3-4 objects now, my ASPX page is running slower. The response from the server (which is my own PC) is taking longer.
With one or two objects, the performance is same. After I instantiate 3, it slows a little, and 4 just completely wears it down.
I've read this article: [URL]
that says to avoid using session variables especially storing objects into them. Well thats exactly what I'm doing. My object has about 10 methods(~30 lines of code each) and 20 fields.
My question is, if I want to persist object in memory for each user session, how else could I store them on each postback if not in the session variable>? I can't use application variable because thats shared and not thread safe.
I am trying to save the every date clicked in a List of Date using a session variable. I am getting a casting error ..."when casting a number the number must be less than infinity".
I have a multiview inside an updatepanel. in one of the views, I save a value in a session object like this:
Session["xyz"] = "some string value";
Then I switch to another view and try to pick it up the value in a button's OnClick event:
string x = Session["xyz"].ToString();
But I get a null reference error. Debugging it shows that Session["xyz"] is indeed null, yet other Session variables are still there. Is there something special about Session and AJAX?
Because of some situation , I had to save users password in session state for short period of time .it unsafe holding some important data in session state?
have some Objects, lets say Employee and Role defined as below and I have defined relationships in my database that gives me a list of objects say employees and thanks to my framework each employee object also has a Role object linked via the RoleIDID, UserName, Password, Email, RoleIDRoleID, RoleNameSo in code I can do something like this