473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problem with SessionState

i have the code in the Page_load event of a toolbar (usercontrol)

If Not Page.IsPostBack Then

If Session("SecurityInfo") Is Nothing Then
Response.Redirect("Default.aspx")
End If

lblUserName.Text = Session.Item("SecurityInfo").UserFullName
lblUserRole.Text = Session.Item("SecurityInfo").Role

subFillProfessionCombo()

RaiseEvent SecurityDetailsLoaded()

Dim strName As Array
strName = Split(Request.ServerVariables("URL").ToString(), "/")
Session("CurrentPage") = strName(UBound(strName))
End If

every so often it falls over on

If Session("SecurityInfo") Is Nothing Then
Response.Redirect("Default.aspx")
End If

and returns the following error

Run-time exception thrown : System.Web.HttpException - Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive

i'm kinda baffled as to why its only falling over sometimes and other times it works fine. and i dont know where to set enableSessionState = true

Nov 19 '05 #1
1 918
Craig,

you can enable Session state on every single page. Simply set the property
EnableSessionState to true. You can do so using the designer or by code.
Another option is to enable session state for all pages. Open web.config and
go to the <pages> - configuration element. Simply add the attribute
enableSessionState="true" to it:

<pages enableSessionState="true" ...>

Regards,
Michael

"Craig G" <craig.gamble@y_arrasoftware.com> schrieb im Newsbeitrag
news:e3**************@TK2MSFTNGP12.phx.gbl...
i have the code in the Page_load event of a toolbar (usercontrol)

If Not Page.IsPostBack Then
If Session("SecurityInfo") Is Nothing Then
Response.Redirect("Default.aspx")
End If
lblUserName.Text = Session.Item("SecurityInfo").UserFullName
lblUserRole.Text = Session.Item("SecurityInfo").Role
subFillProfessionCombo()
RaiseEvent SecurityDetailsLoaded()
Dim strName As Array
strName = Split(Request.ServerVariables("URL").ToString(), "/")
Session("CurrentPage") = strName(UBound(strName))
End If
every so often it falls over on
If Session("SecurityInfo") Is Nothing Then
Response.Redirect("Default.aspx")
End If

and returns the following error

Run-time exception thrown : System.Web.HttpException - Session state can
only be used when enableSessionState is set to true, either in a
configuration file or in the Page directive

i'm kinda baffled as to why its only falling over sometimes and other times
it works fine. and i dont know where to set enableSessionState = true
Nov 19 '05 #2

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

Similar topics

3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
4
by: Aaron Bellante | last post by:
I have been creating some pages that pull info from an SQL database located on my computer. I have an identical DB located on the production machine. The page runs fine on my PC (XP Pro), but...
5
by: Mikko Penkkimäki | last post by:
Hi Looks like I can not change Web page's timeout setting. In practise it's all the time 20 minutes - no matter what I do. I have this kind of setting in web.config: <sessionState...
5
by: sdettmers | last post by:
Hi, Database: SQL Server Session: SQL Server Language: C# Application: ASP.Net I have created a login page which attempts to retrieve the users record from the database and I...
0
by: somnathmali | last post by:
Suppose I have site xyz.com. Site has a page called show_user.aspx where I need to access the Session variables. But this show_user.aspx page will not be called directly Instead , when user type...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.