Handler with IRequiresSessionState does not extend session timeout

后端 未结 1 1496
谎友^
谎友^ 2021-01-25 03:44

I have a handler, like this, using IRequiresSessionState:

public class MyHandler : IHttpHandler, IRequiresSessionState
{
  // code
}

In the cod

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-25 04:37

    Finally got a solution to this... sort of.

    I abandoned trying to get the handler to do the job, and instead called a normal ASPX page. In that page, I removed the HTML code, and used Response.Write(...) to send back some JSON that I wanted. However, even with that, my session was not being extended!

    I finally realized that in the PreRender event, I used Response.ClearHeaders(). That was the problem. It turns out that the Forms authentication system was updating the session ticket cookie when needed, but was adding it to the Headers before my code was running. So when I cleared the headers, I was erasing the new cookie before it was sent to the browser.

    So, if you are having problems with sessions not being extended, check to make sure that your code is not using ClearHeaders()!

    0 讨论(0)
提交回复
热议问题