Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 February 25th, 2005, 04:29 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Session Object Gives Error

I keep getting an error that says...

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive

...when I try to use the Session object. I have Session State enabled in both IIS and in my web.config file.

The only thing I can think of is that maybe the fact that there are some classic ASP pages in the same folder as my ASP.NET web application, maybe that's throwing IIS off. I'm not passing any info from the classic ASP page to the ASP.NET page (that's being done with good old cookie). The error is being thrown between one aspx page and another.

Any ideas?

Aaron

 
Old February 28th, 2005, 12:55 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured this out guys.

You can't declare members like...
 
Quote:
quote:Public myVariable as String = Session ("myVariable")

.NET hates that. You have to declare the member like this...
 
Quote:
quote:Public myVariable as String

And then later on set it equal to your session variable, e.g.
 
Quote:
quote:myVariable = Session ("myVariable")


Seems kind of stupid to me, but oh well.

Aaron

 
Old February 28th, 2005, 12:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You can define it as Dim myVariable As String = <something>. Are you sure that the Session("myVariable") is not nothing. That may be the problem. Also, you can disable session state in the @Page directive, make sure that isn't a factor also.

Brian
 
Old February 28th, 2005, 04:06 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

I get that you can declare members/variables as

Dim myVariable As String = <something>

It's just that .NET doesn't want to do that when the <something> is a value from the session class.

Try it out. Let me know if it works for you.

Aaron

 
Old March 1st, 2005, 01:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Yeah, I do a IsNothing(Session("object")) first to make sure it exists, because then you get an error for that when you convert it.

Dim var as string
If (IsNothing(Session("variable"))) then
  var = Session("variable").ToString()
else
  var = string.emtpy
end if

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
converting .NET error object in VB error object webnet .NET Web Services 0 February 5th, 2007 06:02 AM
Session object error ankur16 Apache Tomcat 0 May 23rd, 2006 04:43 AM
Session object keyvanjan Classic ASP Basics 1 January 25th, 2006 09:32 PM
Session Object mcinar Classic ASP Basics 9 January 9th, 2005 05:41 PM
runtime error '800a01a8' Object Required: 'Session footohi Classic ASP Basics 1 July 17th, 2003 06:32 PM





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