还需要哪部分的?现在在家里,公司的源码看不到,但是那个ajaxserver真的就是那么少,javascript就是放了一个异步连接,什么都没有阿~~~,整个应用都是,只要是用js异步请求的session一定会晚一步,一定要手动访问,或者刷新下那个页面,session才会更新过去,session创建和清空都是一样

解决方案 »

  1.   

    收藏的代码Ajax读写Session值 在服务器端page_load
    AjaxPro.Utility.RegisterTypeForAjax(typeof(test));
    this.Button_Write.Attributes.Add("onclick","WriteSession();");//写session
    this.Button_Read.Attributes.Add("onclick", "ReadSession();");//读session其他写和读的方法
    /// <summary>
    /// 写session
    /// </summary>
    /// <param name="str"></param>
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public void WriteSession(string str)
    {
    Session["UserName"] = str;
    }
    /// <summary>
    /// 读session
    /// </summary>
    /// <returns></returns>
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public string ReadSession()
    {
    string str = "";
    if (Session["UserName"] != null)
    {
    str = Session["UserName"].ToString();
    }
    return str;
    }客户端代码:
    //4、访问Session的值
    //写入
    function WriteSession()
    {
    var str = "HAHA";
    test.WriteSession(str,CallBack_WriteSession);
    }
    function CallBack_WriteSession(res)
    {
    if(res.error == null)
    {
    alert("OK");
    }
    else
    {
    alert(res.error.message);
    }
    }
    //访问
    function ReadSession()
    {
    test.ReadSession(CallBack_ReadSession);
    }
    function CallBack_ReadSession(res)
    {
    if(res.error == null)
    {
    alert(res.value);
    }
    else
    {
    alert(res.error.message);
    }
    }
      

  2.   

    呵呵,谢谢你的代码,但是涉及到和旧版asp的兼容性问题。不能用这种封装的dll,需要手动连接。