• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

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

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
denzmor
Asked:
denzmor
1 Solution
 
razoCommented:
try
 Session("LogValide")="TRUE"
and
  Autorisation = ctype(Session("LogValide"),boolean)
0
 
denzmorAuthor Commented:
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
 
praneethaCommented:
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
denzmorAuthor Commented:
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
 
praneethaCommented:
check what does authorization contaion after line 232..in debug mode

0
 
denzmorAuthor Commented:
it contain = ""
0
 
praneethaCommented:
Session("LogValide") - check what this contains....
0
 
denzmorAuthor Commented:
same thing :S

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

0
 
praneethaCommented:
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
 
denzmorAuthor Commented:
nope doesn't work :S
0
 
praneethaCommented:
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
 
denzmorAuthor Commented:
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
 
praneethaCommented:
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
 
moduloCommented:
PAQed with no points refunded (of 100)

modulo
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now