?
Solved

Cannot Keep my http session state asp.net when response.redirect

Posted on 2004-10-07
16
Medium Priority
?
453 Views
Last Modified: 2006-11-17
Hi, I have 2 aspx file. The first one is the login one. When the connection is ok it make a response.redirect to my official page. The prob, is that in my login page i create some session keys and when i load my second page the value of theses keys are null.... why's that ??? :S

this is the code for my login page where my session is created:
******************************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        'Si on load pas pour la première fois
        If IsPostBack Then
             ChangerTexte(ddlLangue.SelectedItem.Value)

            'On vérifie si l'usager à le droit de se loguer
            If Me.VerifLogin Then
                Me.lErreur.ForeColor = Me.lErreur.ForeColor.Lime
                Me.lErreur.Text = "Connexion en cours veuillez patientez..."

                ChangerTexte(ddlLangue.SelectedItem.Value)

                'On rajoute les session
                Session.Add("LogValide", True)

                Me.Response.Redirect("PrixFontaine.aspx", False)

            End If

        End If

    End Sub
******************************************************************************


this is a function in my second page:
******************************************************************************
Private Function VerifAutorisation() As Boolean

        Dim Autorisation As Boolean
        'on vérifie si l'utilisateur à le droit de voir les données
        Autorisation = Session.Item("LogValide")

        If Autorisation Then
            Return True
        Else
            dectectionErreurActive(True)
            lGestionDocument.Text = ("Vous n'êtes pas autoriser à utiliser ce logiciel")
            Return False
        End If

    End Function
******************************************************************************


I think that's not the same session in my second page, but how can i load the variables of my first page without using cookies...

Thx for the help :)
0
Comment
Question by:denzmor
14 Comments
 
LVL 8

Expert Comment

by:razo
ID: 12248578
try
 Session("LogValide")="TRUE"
and
  Autorisation = ctype(Session("LogValide"),boolean)
0
 
LVL 1

Author Comment

by:denzmor
ID: 12248659
Sorry it doesn't work...

On thing i forgot to mention is that when i compile and test in visual studio it work perfectly( and he using internet explorer as default web browser), i mean the session variable are keeping there values...  but when i run a Internet explorer alone without using visual studio it doesn't work the values are not passed...

so :S
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12248904
Dim Autorisation As String
Autorisation = ctype(Session("LogValide"),String)


 If Autorisation=="True" Then
            Return True

try that...it is very starage that it works from vs.net and not from IE...






0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:denzmor
ID: 12249358
It work in my visual studio like the boolean version but i have an error when i'm using my web browser alone, it trow an System.NullReferenceException at line 234. That means that the variable did not pass the session :S

Ligne 232 :        Autorisation = CType(Session("LogValide"), String)
Ligne 233 :
Ligne 234 :        If Autorisation.Equals("True") Then
Ligne 235 :            Return True
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12249452
check what does authorization contaion after line 232..in debug mode

0
 
LVL 1

Author Comment

by:denzmor
ID: 12249659
it contain = ""
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12249676
Session("LogValide") - check what this contains....
0
 
LVL 1

Author Comment

by:denzmor
ID: 12249804
same thing :S

very weirdo... in visual studio it contain "True" and  without visual studio there's nothing in it...

0
 
LVL 15

Expert Comment

by:praneetha
ID: 12249904
are you going thru the first page from IE...

i mean that is really weird...see if your cookies are disabled...

and try from another comp in your intranet and see if it works...

0
 
LVL 1

Author Comment

by:denzmor
ID: 12250844
nope doesn't work :S
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12250903
how do u know that...

"without visual studio there's nothing in it..."

bcz it throws an exception...insert your code between try and catch and print the exception it throws...

print that using Response.write()



0
 
LVL 1

Author Comment

by:denzmor
ID: 12251054
I found the solution !!!

When in go in the web.config file, i've change the Value of "Cookieless = "true" and now it work. He keep in the url the name of the session id and transfert it to my new page.

Thx for the help anyway praneetha

:)
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12251079
u r welcome... but that still does not explain why it was not working...

so that means the computer u were using ..cookies were disabled in it....
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12572758
PAQed with no points refunded (of 100)

modulo
Community Support Moderator
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question