繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP应用 >> asp 与 asp.net 共享session

asp 与 asp.net 共享session

2006-02-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:  这是一个老话题了,因为最近用的到,所以没办法又到处找资料。微软的网站上提供的是用数据库实现的,总觉得太麻烦,也有说直接使用的,但我没有试成功。我认为直接使用是不可能的。还有一种方法,就是通过几...
关键字:asp session net

  这是一个老话题了,因为最近用的到,所以没办法又到处找资料。微软的网站上提供的是用数据库实现的,总觉得太麻烦,也有说直接使用的,但我没有试成功。我认为直接使用是不可能的。还有一种方法,就是通过几个页面转换,我使用的也是这个方法,通过总结搜索到的资料,整理后编写了几个页面来转换。主要是通过隐藏的input来实现的。具体方法如下:

  asp 转 asp.net 页面:

     用一个asp页,把session信息写到input中,提交给asp.net页

trans.asp

<%

''----------测试数据--------

session("name")="srx"

session("id")="1"

session("sex")="f"

session("pass")="asdfas"

session("age")="23"

session("weight")="131"

''--------------------------

Response.Write("")

for each Item in Session.Contents

    Response.Write("")

next

if len(Request.QueryString("Destpage")) >4 then  

    Response.Write("")

end if

Response.Write("")

Response.Write("frm.submit();")

%>

asptoaspx.aspx

asp.net 转 asp 页面:

     用一个asp.net页,把session信息写到input中,提交给asp页

trans.aspx

aspxtoasp.asp

4 then

  Response.Redirect(Session("DestPage"))

end if

'-----------------------输出所有的Session------------------------------------------------

call allsession() '使用时注释掉此行代码即可

function allsession()

Response.Write "There are " & Session.Contents.Count &" Session variables

"

Dim strName, iLoop

For Each strName in Session.Contents'使用For Each循环察看Session.Contents

 If IsArray(Session(strName)) then '如果Session变量是一个数组? '循环打印数组的每一个元素

  For iLoop = LBound(Session(strName)) to UBound(Session(strName))

    Response.Write strName & "(" & iLoop & ") - " & _

   Session(strName)(iLoop) & "

"

   Next

 Else '其他情况,就简单打印变量的值

  Response.Write strName & " - " & Session.Contents(strName) & "

"

 End If

Next

end function

'------------------------------------------------------------------------------------------

%>

  代码实现的过程中,asp.net页面提交到asp页的时候不能使用Server.Transfer方法,所以只好用Response.Write来自己写Form表单提交。

代码中还有要改进的地方也请各位大虾赐教。

责任编辑:admin
相关文章