Solved

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

Posted on 2004-10-07
16
400 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
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

789 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