Showing posts with label codebehind. Show all posts
Showing posts with label codebehind. Show all posts

Saturday, March 24, 2012

session variable only accessable through page behind class instance?

Are session variables available to any class instance within a project namespace or only for use for the form codebehind class?

I have tried to set a session variable on a code behind class and then retrieve its value in a class instance used by the codebehind class and I get errors. Maybe I'm just not meant to access that way and only codebehind classes (classes that inherit System.Web.UI.Page) can use them?As far as I know session variables are only available in aspx pages.

That does not prevent you from passing value of your session variables to any of your business tier objects.
It's more a question of context.
Within the context of the ASP.NET process, any class can get to the session using HttpContext.Current.Session.
Thanks very much for the help!

Thursday, March 22, 2012

Session Variables - Loosing

Hi,
I am using a web application -asp, ado, C#, using CodeBehind files etc..

I am using "InProc" session state and find that session variables are
loosing their values between one web form and the next. I have used "InProc"
on my development machine and the session variable values are being
maintained between pages.

I copied two of the relevant forms into another application and using
"InProc" session state they maintained their values between forms.

The Global and WebConfig files are virtually identical between applications.

This indicates to me that the problem is somewhere within my application but
I don't know where to start looking from here.

Any suggestions?

Thank YouWe had the same sort of problem here. It took the better part of a week and
another consultant to help out before we finally gave up and just decided
that .NET has real problems with Sessions.

Our solution eventually was to try commenting out different parts of the
code that was being run before the Response.Redirect. We narrowed the bug
down to a Directory.Move command - which really didn't make any sense to us,
but anyway. A Directory.Move just basically renames a directory on the
server's file system, so we tried instead to create a new directory with the
new name, copy the contents of the old directory over, then delete the old
directory (three lines of code instead of one). And Voila! Session keeps
it's state...

"Jonk Eidersteldvr" <hydraline@.cairns.net.au> wrote in message
news:3f4eab09_2@.news.brisbane.pipenetworks.com...
> Hi,
> I am using a web application -asp, ado, C#, using CodeBehind files etc..
> I am using "InProc" session state and find that session variables are
> loosing their values between one web form and the next. I have used
"InProc"
> on my development machine and the session variable values are being
> maintained between pages.
> I copied two of the relevant forms into another application and using
> "InProc" session state they maintained their values between forms.
> The Global and WebConfig files are virtually identical between
applications.
> This indicates to me that the problem is somewhere within my application
but
> I don't know where to start looking from here.
> Any suggestions?
> Thank You
>