asp和.net中 session值可以互传吗? 有一个简单的办法是使用中间页面, 通过 hidden 字段的方法把 session 的值从 asp 发送到 aspx 页面,然后 aspx 页面接受 post 的值,设定相应的所有 session. 反过来也是同理。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个是某外国网站上提出的一个解决方案,我现在正在用这个。 但是原文的链接请恕我找不到了, 只好把代码贴出来给你看: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) & " >")nextif len(Request.QueryString("Destpage")) >4 then Response.Write("<input type=hidden name=destpage value=" & Request.querystring("destpage") & ">")end ifResponse.Write("</FORM>")Response.Write("<scr" + "ipt>t.submit();</scr" + "ipt>")%> asptoaspx.aspx<%@ Page language="c#" CodeBehind="ASPTOASPX.aspx.cs" AutoEventWireup="false" Inherits="ADR.TransferSession.ASPTOASPX" ValidateRequest="false" %><TITLE>ASPTOASPX.aspx</TITLE>asptoaspx.aspx.csusing System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace ADR.TransferSession{ /// <summary> /// ASPTOASPX 的摘要说明。 /// </summary> public class ASPTOASPX : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { Session.Timeout = 60; for(int i=0;i<Request.Form.Count;i++) { Session[Request.Form.GetKey(i)]=Request.Form[i].ToString(); } //Response.Write(Request.Form.Count.ToString()); //Response.Write(Session["DestPage"].ToString()); Server.Transfer(Session["DestPage"].ToString(),true); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion }} 反过来的 aspxtoasp 系列的几个程序你也可以类似的写。我目前在做一个原有的 asp 项目像 aspx 的逐步改造,一个多月前碰到了这个问题。当时找了很多方案,包括在这里翻看帖子。最后确定的是使用这种。因为在我的系统中,设定 session 的地方几乎只有用户登陆的时候记录他的登陆信息。 所以我可以集中管理。 利用这种方法, 在登陆成功后的程序中, 从 asp 跳转到这几个中间页面, 往 aspx 中记录一下已有的 session, 然后跳转到原来需要转向的页面。(在我这个项目中就是用户进去的首页)这个的缺点就是登陆的时候有时候会觉得慢一些,因为要经过两三个页面的跳转。 不过这个没什么关系,后面就能够正常的使用 asp.net 的优秀功能了。 总体来说,我觉得有些落后的 asp 项目在不允许废掉重新做的情况下, 采用这种 asp + aspx 的混合解决方案还是合适的。 这个网站的源代码怎么去取?从来没有见过这样的,各位遇到过吗 c# sql 上位机 的问题 WCF 设计结构? Windows控件的最小化代码怎么写 想找一个现在也是用C#开发的人做网友,大家能互相帮助一下. 如何在DataGrid(应用程序的控件非web)里添加一个checkBox控件,以及如何知道那一行被选中。 谁知道vs2005专业版,标准版,还有企业版的区别?谢谢! 如何在线程中为TreeView添加项目? 推荐outlookbar控件 问个简单的东西!QuickStart是什么玩意? 有史以来碰到的最奇怪的一个问题!欢迎大家发表高见! 指针:这个的效率能再提高么(本贴可加分)
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) & " >")
nextif len(Request.QueryString("Destpage")) >4 then
Response.Write("<input type=hidden name=destpage value=" & Request.querystring("destpage") & ">")
end ifResponse.Write("</FORM>")
Response.Write("<scr" + "ipt>t.submit();</scr" + "ipt>")
%>
<TITLE>ASPTOASPX.aspx</TITLE>
asptoaspx.aspx.csusing System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace ADR.TransferSession
{
/// <summary>
/// ASPTOASPX 的摘要说明。
/// </summary>
public class ASPTOASPX : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
Session.Timeout = 60; for(int i=0;i<Request.Form.Count;i++)
{
Session[Request.Form.GetKey(i)]=Request.Form[i].ToString();
} //Response.Write(Request.Form.Count.ToString());
//Response.Write(Session["DestPage"].ToString()); Server.Transfer(Session["DestPage"].ToString(),true);
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}