using System;
using System.Web;
using System.Web.SessionState;
using System.Web.Script.Serialization;
public class ReadSession : IHttpHandler,IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Key = context.Request["key"],
Value = (context.Session[context.Request["key"]]!=null && context.Session[context.Request["key"]]!="" ? context.Session[context.Request["key"]]:"")
}));
}
public bool IsReusable
{
get { return true; }
}
}
/*-------( In jquery just call like this )--------*/
$.getJSON('/ReadSession.ashx', { key: key }, function (result) {
alert(result.Value);
});
using System.Web;
using System.Web.SessionState;
using System.Web.Script.Serialization;
public class ReadSession : IHttpHandler,IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Key = context.Request["key"],
Value = (context.Session[context.Request["key"]]!=null && context.Session[context.Request["key"]]!="" ? context.Session[context.Request["key"]]:"")
}));
}
public bool IsReusable
{
get { return true; }
}
}
/*-------( In jquery just call like this )--------*/
$.getJSON('/ReadSession.ashx', { key: key }, function (result) {
alert(result.Value);
});
No comments:
Post a Comment