473,626 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session["UserName"]

Hi,

I use Session["UserName"] to save and pass values between pages, (please see
the following). It works fine on my computer, but on the server, I launch the
main page, wait for 20 minutes, and click a button to launch User.aspx, it
seems that it cannot see the current value of Session["UserName"]. There's no
problem to launch User.aspx from the main page within 20 minutes. Please
help. Thanks.

//Users.aspx
if (!Page.IsPostBa ck)
{
if (Convert.ToStri ng(Session["UserName"]) != "")
{
//Do something
}
}

Jun 27 '08 #1
3 2278
"John" <Jo**@discussio ns.microsoft.co mwrote in message
news:C6******** *************** ***********@mic rosoft.com...
I use Session["UserName"] to save and pass values between pages, (please
see
the following). It works fine on my computer, but on the server, I launch
the
main page, wait for 20 minutes, and click a button to launch User.aspx, it
seems that it cannot see the current value of Session["UserName"]. There's
no
problem to launch User.aspx from the main page within 20 minutes.
20 minutes is the default time that a session exists before it is torn down
to conserve server resources.

Either increase the session timeout value,
http://www.google.co.uk/search?sourc...sion%2eTimeout

or change your logic...
http://www.google.com/search?q=Sessi...e7&rlz=1I7GGIH
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
Also, the simples way of testing to see if a session variable exists is to
see if it's null or not. Converting it to a string first is a waste. Just do
if(Session["UserName"] != null)
{
Do Something
}

This also helps prevent errors from being thrown if you attempt to convert
upon a null object.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

"John" <Jo**@discussio ns.microsoft.co mwrote in message
news:C6******** *************** ***********@mic rosoft.com...
Hi,

I use Session["UserName"] to save and pass values between pages, (please
see
the following). It works fine on my computer, but on the server, I launch
the
main page, wait for 20 minutes, and click a button to launch User.aspx, it
seems that it cannot see the current value of Session["UserName"]. There's
no
problem to launch User.aspx from the main page within 20 minutes. Please
help. Thanks.

//Users.aspx
if (!Page.IsPostBa ck)
{
if (Convert.ToStri ng(Session["UserName"]) != "")
{
//Do something
}
}
Jun 27 '08 #3
And managing the user is really a no-brainer when using ASP.NET 2.0
"John" <Jo**@discussio ns.microsoft.co mwrote in message
news:C6******** *************** ***********@mic rosoft.com...
Hi,

I use Session["UserName"] to save and pass values between pages, (please
see
the following). It works fine on my computer, but on the server, I launch
the
main page, wait for 20 minutes, and click a button to launch User.aspx, it
seems that it cannot see the current value of Session["UserName"]. There's
no
problem to launch User.aspx from the main page within 20 minutes. Please
help. Thanks.

//Users.aspx
if (!Page.IsPostBa ck)
{
if (Convert.ToStri ng(Session["UserName"]) != "")
{
//Do something
}
}
Jun 27 '08 #4

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

Similar topics

5
12398
by: lsarg | last post by:
i've been trying forever to figure out a way to use a regular text link in place of a submit button at the bottom of this. can't get it. i'm just starting to learn php, so i'm stuck. any help at all would be amazing. <?php # Script 12.7 - login.php // This is the login page for the site. // Include the configuration file for error management and such.
3
2171
by: mallyonline | last post by:
I last posted to this group about 6 months ago and was very pleased by the excellent response I got and the great help offered to me. I am back this time with another request for your expert help on a bit of ASP code I use on my windows server 2003 with IIS6 machine. I would like the code below to display in different colours depending on the status of the page. I am looking to make the not logged in code appear red and the logged in...
3
4545
by: Carpe Diem | last post by:
Hello I have an aspx page that loses Session("user") value after a few minutes even after I set <sessionState mode="InProc" cookieless="false" timeout="300"> in web.config and wrote function Session_Start() { Session.Timeout = 3000; } in global.asax
9
3168
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated Windows authentication. The error occurs on the FindAll method. The exceptions are as follows. anyway of getting the code working with Integrated Windows authentication (too annoying for user to enter user-name/password). Note I do need to use...
3
1752
by: TCB | last post by:
Hi, There are a couple of things that are bothering me, any help on these is greatly appreciated. This is using ASP.NET 2.0 1. I am sending email in my web app, using a simple form here is the code: Dim MyMailFrom As New Net.Mail.MailAddress("portal@xxx.com", "Portal XX.com") Dim MyMailTo As New Net.Mail.MailAddress("info@xxx.com")
2
1368
by: alain.hogue | last post by:
I known that by using the "Profile_MigrateAnonymous" event I can migrate my anonymous users profile to their authenticated account profile, but I would like to carry over some of the properties of their authenticated account profile back to anonymous profile when they logout. How can I do that? Thanks !
4
5933
by: three-eight-hotel | last post by:
I'm somewhat of a newbie to PHP coding, but have developed a site using the technology, and have been pleasantly surprised by the capabilities offered. I am more comfortable in the ASP world, however and am really struggling with managing sessions in PHP, based on my experiences with managing sessions in ASP. 99.9% of the feedback I have seen when dealing with the errors has referred to having whitespace before the <?php or after the...
1
2349
by: patelxxx | last post by:
Hi Guy's, I'm getting the error: "Username or password did not match" BEFORE I even enter a username and password, can someone help? 1) The site I'm accessing is: http://www.valuemapping.co.uk/VMSE/ 2) Then I click/select the following application: "VMSE Reporting" and get the above error. The CGI script for this is:
1
3553
by: murthychvrm | last post by:
why we declare "ReportDocument doc;" in this coding?what it is doing here? using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI;
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.