我的页面a(html页面,使用ajax向ashx文件获取某个session值),跳转到页面b(aspx页面,对session赋值,然后跳转到页面a)
无论在页面b赋什么值,在页面a上始终看到的是第一次session的赋值。
请问这个怎么解决啊!谢谢大家了~~~~~

解决方案 »

  1.   

    页面a代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>
    </head>
    <body>
        <form>
            <script language="javascript" type="text/javascript">
            var http_request = false;
            function send_request(url) { //初始化、指定处理函数、发送请求的函数
                http_request = false;
                //开始初始化XMLHttpRequest对象
                if(window.XMLHttpRequest) { //Mozilla 浏览器
                    http_request = new XMLHttpRequest();
                    if (http_request.overrideMimeType) {//设置MiME类别
                        http_request.overrideMimeType('text/xml');
                    }
                }
                else if (window.ActiveXObject) { // IE浏览器
                    try {
                        http_request = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch (e) {
                        try {
                            http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e) {}
                    }
                }
                if (!http_request) { // 异常,创建对象实例失败
                    window.alert("不能创建XMLHttpRequest对象实例.");
                    return false;
                }
                http_request.onreadystatechange = processRequest;
                // 确定发送请求的方式和URL以及是否同步执行下段代码
                http_request.open("GET", url, true);
                http_request.send(null);
            }
            // 处理返回信息的函数
            function processRequest() {
                if (http_request.readyState == 4) { // 判断对象状态
                    if (http_request.status == 200) { // 信息已经成功返回,开始处理信息
                        document.getElementById("aa").innerHTML = http_request.responseText
                    } else { //页面不正常
                        alert("您所请求的页面有异常。");
                    }
                }
            }
            function getLoginName() {
                    send_request('Handlers/Handler.ashx');
            }
            </script>
            <div id="aa"></div>
            <a href="b.aspx">我去登陆下</a>
            <input id="Text1" type="text" onkeypress="getLoginName();" />
            <script language="javascript" type="text/javascript">
                getLoginName();
            </script>
        </form>
    </body>
    </html>
    页面b部分程序
        protected void Button1_Click(object sender, EventArgs e)
        {
            Session["IsLogin"] = this.TextBox1.Text;
            Response.Redirect("a.htm");
        }ashx程序
    <%@ WebHandler Language="C#" Class="Handler" %>using System;
    using System.Web;public class Handler : IHttpHandler, System.Web.SessionState.IReadOnlySessionState {
          public void ProcessRequest (HttpContext context) {
              context.Response.ContentType = "text/plain";
              string strReturn = "";
              if (context.Session["IsLogin"] != null)
              {
                  context.Response.Write(context.Session["IsLogin"].ToString().Trim());
              }
              else
              {
                  context.Response.Write("都登陆你,你丫还说我没登陆!");
              }
          }    public bool IsReusable
        {
            get { return false; }
        }}
      

  2.   

    Handler处理中的命名空间吗?
    加什么样的命名空间啊!?
      

  3.   

    自己把问题解决了!
    处理程序中加入context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    可以使同样的传值时不调用之前的缓存!
      

  4.   

    MyHandler : IHttpHandler, IReadOnlySessionState这样继承一下 就可以使用 session 了
      

  5.   

    context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    加在什么地方啊
      

  6.   

    我也遇到一模一样的问题 ,我的报错信息可能不一样,但我想实现的功能和你的是一样的,我是取不到SESSION值  能否通过QQ告诉我啊?  我的QQ334072556  我接触.NET不是很久