views:

31

answers:

1

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

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

+1  A: 

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

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
}
Nick Craver
i have dis codepublic void ProcessRequest(HttpContext context) { //You can use session here }but how to use context to chek if the user is logged in
vakas
@vakas - That depends what login provider you're using, Forms, something else? It's the same way you'd check in any other page in your application, e.g. `if(Session["LoggedIn"] != null)` as a simple (though bad!) example, or say if you're storing a user object, `Session["user"] != null`....whatever your check is.
Nick Craver
hmm... i got it thnx........
vakas