如何用ajax重置asp.net会话?

时间:2020-11-25 03:27:03

I am trying to reset an asp.net session with ajax, but it's not working. What do I need to do to trigger a reset on the session time or IIS worker process

我正在尝试使用ajax重置asp.net会话,但它无法正常工作。如何触发会话时间或IIS工作进程的重置,我需要做什么

[WebMethod]
public static bool KeepAlive()
{
      return true;
}

2 个解决方案

#1


6  

Not totally sure, but I think the session timer will be triggered if you use the WebMethod attribute like this:

不完全确定,但我认为如果你使用这样的WebMethod属性会触发会话计时器:

[WebMethod(EnableSession=true)]
public static bool KeepAlive()
{
    return true;
}

I would try it out myself, but I'm using my mac atm... :P

我会自己尝试一下,但我正在使用我的mac atm ...:P

#2


0  

If EnableSession is true, then any request will reset the session to start at the beginning. However the IIS worker process is controlled by the Application Pool settings and cannot be controlled by an external request of some sort.

如果EnableSession为true,则任何请求都会重置会话以从头开始。但是,IIS工作进程由应用程序池设置控制,不能由某种外部请求控制。

#1


6  

Not totally sure, but I think the session timer will be triggered if you use the WebMethod attribute like this:

不完全确定,但我认为如果你使用这样的WebMethod属性会触发会话计时器:

[WebMethod(EnableSession=true)]
public static bool KeepAlive()
{
    return true;
}

I would try it out myself, but I'm using my mac atm... :P

我会自己尝试一下,但我正在使用我的mac atm ...:P

#2


0  

If EnableSession is true, then any request will reset the session to start at the beginning. However the IIS worker process is controlled by the Application Pool settings and cannot be controlled by an external request of some sort.

如果EnableSession为true,则任何请求都会重置会话以从头开始。但是,IIS工作进程由应用程序池设置控制,不能由某种外部请求控制。