如何在ajax中检查会话

时间:2022-12-10 07:18:37

i want to chek is the user is loggedin before hitting the ajax request or i want to chek in ajax handler(ashx file)

我想chek是用户登录ajax请求之前登录或我想在ajax处理程序(ashx文件)chek

i have httpContext there in ashx file can i chek thru dis?

我在ashx文件中有httpContext,我可以通过dis?

1 个解决方案

#1


1  

In your IHttpHandler (.ashx handler) handler make it implement the IReadOnlySessionState or IRequiresSessionState (if it needs to set anything) interfaces, like this:

在你的IHttpHandler(.ashx处理程序)处理程序中,它使它实现IReadOnlySessionState或IRequiresSessionState(如果它需要设置任何东西)接口,如下所示:

public class MyHandler : IHttpHandler, IReadOnlySessionState
{
  public void ProcessRequest(HttpContext context) 
  {
    //You can use session here
  }
  public bool IsReusable { get { return true; } } //this may vary for you
}

#1


1  

In your IHttpHandler (.ashx handler) handler make it implement the IReadOnlySessionState or IRequiresSessionState (if it needs to set anything) interfaces, like this:

在你的IHttpHandler(.ashx处理程序)处理程序中,它使它实现IReadOnlySessionState或IRequiresSessionState(如果它需要设置任何东西)接口,如下所示:

public class MyHandler : IHttpHandler, IReadOnlySessionState
{
  public void ProcessRequest(HttpContext context) 
  {
    //You can use session here
  }
  public bool IsReusable { get { return true; } } //this may vary for you
}