티스토리 뷰

첫 페이지는 Classic ASP 페이지다.

여기서 최초 세션을 생성한다.

마지막에 ASPPage2.asp 로 이동한다.

 

<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
Session("DestPage")="Finalpage.aspx"
Server.Transfer("ASPPage2.asp")
%>

==========================================================================

두번째 페이지는

첫페이지에서 생성한 세션들을

폼과 히든 필드를 이용하여 ASP.NET 페이지로 던져준다.

 

<TITLE>ASPPage2.asp</TITLE>
<%
' We graf all the session variable names/values and stick them in a form
' and then we submit the form to our receiving ASP.NET page (ASPNETPage1.aspx)...
Response.Write("<form name=t id=t action=ASPNETPage1.aspx method=post >")
For each Item in Session.Contents
Response.Write("<input type=hidden name=" & Item)
Response.Write( " value=" & Session.Contents(item) & " >")
next
Response.Write("</FORM>")
Response.Write("<script>t.submit();</script>")
%>

============================================================================

Classic ASP 페이지의 폼을통해 전송된 변수들을

ASP.NET 세션에 담는다.

DestPage 라는 세션변수의 값에 담겨진 주소로 이동한다.


<TITLE>ASPNETPage1.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();
    }
    Server.Transfer(Session["DestPage"].ToString(),true);
}
</script>
==============================================================================

마지막 페이지로서

Classic ASP 와 ASP.NET 모두 세션변수를 공유하게 되었다.

 

<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>

 

[원문] http://www.eggheadcafe.com/articles/20021207.asp

댓글