0

Hi,

I am currently taking care of a website that goes back to 1997 and mostly all programmed with Asp 2.0 and vbscript, while i keep the pages in Asp 2.0 when i have to update them, this week i had to implement some new pages, and since we are currently doing the analysis of remaking the whole system with current technology, i figured what i would add during the analysis process could already be Asp.NET, and my superior agreed. Little did we know that asp and asp.NET save application and session variables differently from what i understand , and so the pages on each languages use their respective sets of variables.

Now MSDN offers a way to go about converting a system in stages and therefor sharing the variables but it all sounded pretty overkill for the 2-3 pages i had to add at the moment, instead i found this very good idea :

Session sharing between asp and asp.net

best part is , it works! still trying to make the other way arround work but thats for another time, right now let's get to what brought me to post here.

While im testing this method i find that my 6 Session variables convert to 7 from asp to asp.net ... with the Session("Is_a_member") being duplicated, while looking for anwsers yesterday, my session timed out, and since i was down to 0 asp.net session variables i went back to the copying page then back to my aspx page, and i was up to 8 variables! Is_a_member being there 3 times.

Heres some of the code i adapted from the link above to my environement :

code behind for asp -> asp.net

Partial Class ApplicationCopy
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim i As Integer
        For i = 0 To Request.QueryString.Count - 1
            If Request.QueryString(i) = "" Then
                Application(Request.QueryString.GetKey(i)) = ""
            Else
                Application(Request.QueryString.GetKey(i)) = Request.QueryString(i).ToString()
            End If
        Next
        Response.ContentType = "image/gif"
    End Sub

End Class
Partial Class SessionCopy
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim i As Integer
        For i = 0 To Request.QueryString.Count - 1
            If Request.QueryString(i) = "" Then
                Session(Request.QueryString.GetKey(i)) = ""
            Else
                Session(Request.QueryString.GetKey(i)) = Request.QueryString(i).ToString()
            End If
        Next
        Response.ContentType = "image/gif"
    End Sub

End Class

and heres the img tags i put in the asp pages to call the copying pages :

<img src="SessionCopy.aspx?<%
        dim sItem, i
        i= 0
        For each sItem in Session.Contents
            if i <> 0 then
                Response.Write("&")
            end if
                Response.Write(sItem & "=" & Server.UrlEncode(Session.Contents(sItem))) 
            i= i + 1
        next 
    %>" height="1" width="1" style="display:none" alt=""/>
	<img src="ApplicationCopy.aspx?<%
        i= 0
        For each sItem in Application.Contents
            if i <> 0 then
                Response.Write("&")
            end if
                Response.Write(sItem & "=" & Server.UrlEncode(Application.Contents(sItem))) 
            i= i + 1
        next 
    %>" height="1" width="1" style="display:none" alt=""/>

If anyone could explain how it is even possible to have two session variables with the same key it would be awesome.

Ps : no problem was noted on the application variables so far, the numbers always match

1
Contributor
1
Reply
7
Views
5 Years
Discussion Span
Last Post by Philippe.Lahaie
0

Well I came back from christmas break and i couldn't reproduce the problem i was having before leaving in december.

Since i can't tell if the error is gonna come back someday randomly i figured for the time being id just keep all the pages in my site in Asp 2.0

Ill mark this thread as solved but i hope it helps other people trying to implement a similar solution to bypass Microsofts' suggestion.

Edited by Philippe.Lahaie: typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.