If Not IsPostBack Then
'Response.Write(Request.Form("Hidden1"))
Dim cookie As HttpCookie = Request.Cookies("SendSql")
If Not cookie Is Nothing Then
Response.Write(cookie.Value)
End If
End If
<TITLE>ASPTOASPX.aspx</TITLE>
<%@ Page language="c#" %>
<script runat=server>
// We iterate through the Form collection and assign the names and values
// to ASP.NET session variables! We have another Session Variable, "DestPage"
// that tells us where to go after taking care of our business...
private void Page_Load(object sender, System.EventArgs e)
{
for(int i=0;i<Request.Form.Count;i++)
{
Session[Request.Form.GetKey(i)]=Request.Form[i].ToString();
}
//Response.Write(Session["DestPage"].ToString());
Server.Transfer(Session["DestPage"].ToString(),true);
}
</script>
<TITLE>ASPPage1.asp</TITLE>
<%
' This is the page where we just set some Classic ASP Session Variables
' ASPPage2.asp is where the work is done.
Session("username")="joeblow"
session("email")="joe@blow.com"
Session("userid")=2
' don't use next two lines if using hyperlink as below in page portion
'Session("DestPage")="Finalpage.aspx"
'Server.Transfer("ASPTOASPX.asp")
%>
<a href="ASPTOASPX.asp?destpage=Finalpage.aspx">go to FinalPage.aspx</a>
asptoaspx.asp
<%
Response.Write("<form name=t id=t action=ASPTOASPX.aspx method=post >")
for each Item in Session.Contents
Response.Write("<input type=hidden name=" & Item)
Response.Write( " value=" & Session(item) & " >")
next
if len(Request.QueryString("Destpage")) >4 then
Response.Write("<input type=hidden name=destpage value=" & Request.querystring("destpage") & ">")
end if
Response.Write("</FORM>")
Response.Write("<scr" + "ipt>t.submit();</scr" + "ipt>")
%>
FinalPage.aspx
<TITLE>FinalPage.aspx</TITLE>
<%@ Page language="c#" %>
<script runat=server>
// This page is just a "proof of concept page"...
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("Shared Session Variable Names/Values between Classic ASP and ASP.NET:<BR>");
for (int i = 0; i < Session.Contents.Count; i++)
{
Response.Write("Assigned to \"" +Session.Keys[i].ToString()+"\"");
Response.Write(" Value: "+ Session[i].ToString() +"<BR>");
}
}
</script>