Lost of session when redirecting from vbscript

Zmtzzypcjk

New Member
Update: We got a website (projectA) that is really old and I need to do a new one (ProjectB). We are moving from ASP to ASP.NET. Project A and B are on the same machine. In ProjectB, I created a webpage ( login.aspx ) that redirect to a page in ProjectA (admin.asp).In ProjectA, there is sessions so here's the thing. I want to create ProjectA's session FROM ProjectB. I read some article on how to do this and wrote some code but I'm stuck.In my ProjectB login.aspx I create my sessions variable and redirect to ProjectB "ASPNETToASP.aspx"\[code\]Session.Add("SessionNoClient", "1272");Session.Add("CurrentQuote", "-1");Session.Add("UnitSystem", "0");Session.Add("SessionAdministrator", "0");Response.Redirect("../../ASPNETToASP.aspx?destpage=../ASP MenuAdmin.asp");\[/code\]In ProjectB "ASPNETToASP.aspx", I use all sessions and move them into a form and submit it to ProjectB "ASPFromASPNET.asp"\[code\]protected void Page_Load(object sender, EventArgs e) { string sForm = "<form name='t' id='t' action='http://www.flofab.com/HomeSite/ASPFromASPNET.asp' method='post' >"; // Get all session parameters for(int i = 0; i < Session.Count; i++) { sForm += "<input type='hidden' name='" + Session.Keys.Get(i) + "' value='" + Session.ToString() + "' />"; } // Get all $_GET for (int i = 0; i < Request.QueryString.Count; i++) { if (Request.QueryString.Keys.Get(i) == "destpage") sForm += "<input type='hidden' name='" + Request.QueryString.Keys.Get(i) + "' value='" + Request.QueryString.Get(i) + "' />"; else sForm += "<input type='hidden' name='querystring_" + Request.QueryString.Keys.Get(i) + "' value='" + Request.QueryString.Get(i) + "' />"; } sForm += "</form>"; sForm += "<script>t.submit();</script>"; Response.Write(sForm); }\[/code\]Note the full path is used in form action because I'm having a POST verb error if I'm giving only the relative path. With this form submit, I'm creating all my session on ProjectB "ASPFromASPNET.asp"\[code\]<%@ Language=vbscript %><%Dim queryString Dim destpage Dim fieldName Dim fieldValue For Each Item in Request.Form fieldName = Item fieldValue = http://stackoverflow.com/questions/11614450/Request.Form(Item) length = Len(fieldName) if length > 11 Then leftName = Left(fieldName, 12) rightName = Right(fieldName, length - Len(leftName)) if leftName ="querystring_" Then if queryString <> "" Then queryString = queryString & "&" End If queryString = queryString & rightName & "=" & fieldValue End If End If if Item = "destpage" then destpage = fieldValue End If Session(fieldName) = fieldValue Next If queryString <> "" then Session("destpage") = destpage & "?" & queryString End If For Each Item in Session.Contents Response.Write(Item & "=" & Session(Item) & "<br />") Next Response.Redirect (Session("destpage"))\[/code\]When writing all sessions, all items are displayed correctly. When I redirect to the Session("destpage") which is "../ASP MenuAdmin.asp", my sessions does not seem to exists so I'm getting redirected to ProjectA login (where sessions were created). When looking at those inputs in ASP Menu.asp, values are set to nothing.\[code\]<% var mysession = Session("SessionNoClient"); var dest = Session("destpage");%> <input type="hidden" name="test" id="test" value='http://stackoverflow.com/questions/11614450/<% =mysession %>' /> <input type="hidden" name="test2" id="test2" value='http://stackoverflow.com/questions/11614450/<% =dest %>' />\[/code\]Can you guys can see any error in my code that would not keep sessions?
 
Back
Top