Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2008, 03:50 PM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strange session isues

I've created some pages in TBH that use gridviews and detailviews to display or edit data. I have them pulling parameters from session variables. In testing when I add a new user and go through them everything works pretty well but when I logout and login as another user sometimes those variables are blank sometimes they are values from the previous login. When I hit refresh some times it clears up the problem sometimes not.

As a newbie some of the subtler aspects of cookies, caching and session timeouts are pretty mysterious to me but I think the problem lies in there somewhere.

Can anyone help? Thanks,

Shawn
 
Old December 17th, 2008, 03:59 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Can you recreate the issue in a brief sample and post it? It would be difficult to diagnose what problem you're having without seeing what you're doing.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 17th, 2008, 04:24 PM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
Can you recreate the issue in a brief sample and post it? It would be difficult to diagnose what problem you're having without seeing what you're doing.
I have this in the codebehind of the template.master:

protectedvoid Login_LoggedIn(object sender, EventArgs e)
{
Login lg = sender asLogin;
SqlConnection myConnection;
SqlCommand myCommand;
SqlDataReader myDataReader;
string connectionString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;

myConnection =
newSqlConnection(connectionString);
myConnection.Open();
//prepare sql statements
myCommand = newSqlCommand("SELECT family_id FROM family WHERE user_name = @user", myConnection);
myCommand.Parameters.Add(
"@user", SqlDbType.VarChar, 30);
myCommand.Prepare();
myCommand.Parameters[
"@user"].Value = lg.UserName;
myDataReader = myCommand.ExecuteReader();
myDataReader.Read();
if (myDataReader.HasRows)
{
Int32 familyId = myDataReader.GetInt32(0);
Session[
"FamilyID"] = familyId;
}
myConnection.Close();
}

But then when I go to another page that displays the family_id in a label and then retrieves a gridview using it as parameter they are both blank. Or sometimes they have the id number of the previous login. Sometimes I refresh in the browser and nothing changes sometimes it brings up the correct id.

Thanks.
 
Old December 17th, 2008, 05:08 PM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

A further test result. On the page after I run that code when it first comes up it shows the FamilyID as blank, I wait one minute, hit browser refresh and now it is correct.

Que the twilight zone music...
 
Old December 17th, 2008, 05:35 PM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another quick test result. It doesn't happen with the ASP.Net development server only on the production server: 2003/IIS 6.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange problem... F3553 C++ Programming 1 October 25th, 2007 03:56 PM
Really Strange... nooor83 BOOK: Professional Ajax ISBN: 978-0-471-77778-6 7 May 7th, 2006 12:51 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM
PostBack Isues in asp.net madhav_srivastava ASP.NET 1.0 and 1.1 Professional 1 December 10th, 2004 01:03 PM
strange behaviour: session variable/virtual host ahfaich Pro PHP 8 May 12th, 2004 11:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.