Web Forms :: Session.sessionid Returns Different Value With Each Postback?
Sep 28, 2010
I'm a bit stumped by this one. Have a VS 2008 website running on Windows 7 using the VS web server. One of the pages transfers to another page (page2). On page2, each time I cause a postback by clicking a button, I get a different session.sessionid. I was under the impression sessionid was constant throughout the session, i.e. until the browser is closed or the session expires (~20 minutes). Is this just a VS web server quirk?
I have used Session.SessionID property, but it's keep on changing on every page postback.....can we keep it same untill user sign out from his account..?
i want to generate the new sessionid in the same httpcontext once the user is successfully authenticated.so, how can i do that ? ( please dont ask why do you want it, i got such kind of requirement).
I'm storing the session IDs of the logged-in users in a database, so I need to kill some sessions using the session Ids stored in the database, but unfortuently I'm not able to get any session using the seesion ID so that I can kill it.
I'm writing some logging code that is based on SessionID. However, when I log out (calling Session.Abandon), and log in once again, SessionID is still the same. Basically every browser on my PC has it's own session id "attached", and it won't change for some reason. My Session config looks like this:
To avoid session fixation/hijacking we are heeding the common advice to create a new ASP.Net session for a user after authentication. Sounds simple enough. When a user authenticates we call Session.Abandon() the session ID cookie Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", "") then redirect the user.
However, how do we know on the new page that the user has logged in? We cannot check a session variable because there are none, we just started a brand new session.
I would swear, though I cannot find it now, that on this site someone explained how you can abandon a session and then get the next subsequent session ID. This way you could store that information. Then on the "Start Page" a new session would begin and that page could look up the old Session based on the new ID and validate that a user logged in.
So, are there any masters of the ASP.Net Session classes that know how to do this?
I am searching to find a way to read and write on session data but with out having the HttpContext.Current.Why I won to do that ?, because I wish to make some action with the user Session after the page have been close and unloaded. For example, a user load and see a page, then I create a thread to make some action and let user go. Inside this thread I like to read the session data, but in this case HttpContext.Current is not exist any more.
So is there a way to read Session Data knowing just the session id.I store my session inside an sql server, and I see them... its there on table ASPStateTempSessions . How can I read them "offline" and manipulate them ?
I hav a problem where I wanted to share session state between main page and subdomain page (example between [URL]. Naturally, in this case, the webserver will give me a different session id because the session id is bound to the domain.
But how can i override the sessionid of my main page when I come back to it?
to set a new sessionId on sign out, but when the session expires, the sessionId is reused if the browser instance is not closed. In my web.config I have used
but still get sessions reused. I can't kill the cookie in Session_end() because I don't have access because there is no HttpContext or request, so I can't reset it that way. how I can force a new sessionId from the Global.asax.cs file?
One selects items from the dropdown lists and click the Search button.
The ListView displays all the entries that match the criteria.
STEP 2:
Each entry in the ListView is clickable to select more details in the FormView.
Everything works perfectly well. However I'm testing the selected values after each postback based on the following script:
[Code]....
Now after STEP 1 (Search button) I get the selected ddl values. GREAT so far.
However in STEP 2 and in order to get the selected value of theListView I have to click twice on the same entry in the ListView. The ListView1.SelectedValue is returning 0 after the first click. The correct value is displayed after the second click.
i have two web aplications running on different sites.
1. site gets user information and show another website (2. site) in an i frame. but when i do this 2. site session starts again on every page.postback . if i connect to 2. site without 1. site everything works well.
I have a simple page containing a GridView control that generates thead and tbody tags after rendering. In my jQuery script, I have a line that reads this way:
$('#GridView1 thead').eq(0).html()
When the page loads for the first time, this script returns an objects and works well. But when I click a button and cause a postback, it returns null. By the way, the button changes the number of the rows returned from the data source (based on the value of a textbox) and updates the grid.
I have a page where, when the user has successfully logged in, I store some values in the session.
I then use these values to load an application list page. This page is automatically refreshed after 20.1 minutes, with the sessionstate timeout and forms timeout in web.config set to 20 minutes (with sliding expiration). This means, if the user does not use any page for more than 20 minutes, he is timed out.
My problem is that the User.Identity.IsAuthenticated sometimes returns true, when the session has expired.
I'm evaluating using Ajax in a new project and so I've developed a simple web page to test a few things, however even the simplest task seems to cause my session to be cleared. I am using VS2008 with .Net 3.5 SP1 and the page is in my existing solution which has several custom handlers and modules in the web.config. Below is the code I'm using, it's a simple test which puts a variable into the session then on the buttons postback tries to get the same variable, however it always fails as the session is blank.
I have a calculation in a gridview rowdatabound event that stores a value in a session variable. The problem is that after the page is viewed the first time, the value continues to accumulate each time it is posted back. How can I calculate the value the first time and stop it from continuting to recalculate and add to itself each time the page is reloaded?
I have a simple ASP.NET 4 site. I am using Forms Authentication. I have Session timeout set to 20 minutes. Also when the user authenticates I set the AuthenticationTicket to expire in 20 minutes. So normally everything works fine. If there is more than 20 minutes of inactivity and the user requests a page on the site they are redirected back to the Login page as I would expect.
However, let's say that the user is on a page that contains a form. Then they wait 25 minutes. Then they go to submit the form. Instead of being redirected back to the Login page, the site attempts the postback and I immediately get errors because there is code in the postback that attempts to get information out of Session.
It seems like ASP.NET does not redirect back to Login on postback if the AuthenticationTicket and Session has expired. How can I handle this? I hope I don't have to write special code on each page.
When i press the delete button, everything works fine and the folder gets deleted. but after that when page postbacks again then a NullRefrenceException is raised at Label1.Text = Session["loginid"].ToString(); why is it happening...?? When I am not using this Directory.Delete() method everything is working fine and session variables are not set to null. When I traced my application I found that After Directory.Delete() method Session variables were intact and I was able to use those session variables in the processing after Directory.Delete(). But as soon as the page postbacks all session variables are set to null. And this problem doesn't appear when i m not using this delete() method. The folder I m deleting is in my project's folder. I m running this website using Visual Studio.