Solved

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

Posted on 2004-10-07
16
367 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
16 Comments
 
LVL 8

Expert Comment

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

Author Comment

by:denzmor
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:denzmor
Comment Utility
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
Comment Utility
check what does authorization contaion after line 232..in debug mode

0
 
LVL 1

Author Comment

by:denzmor
Comment Utility
it contain = ""
0
 
LVL 15

Expert Comment

by:praneetha
Comment Utility
Session("LogValide") - check what this contains....
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:denzmor
Comment Utility
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
Comment Utility
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
Comment Utility
nope doesn't work :S
0
 
LVL 15

Expert Comment

by:praneetha
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with no points refunded (of 100)

modulo
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now