使用Ajax Call在Asp.net中的会话超时问题

时间:2011-04-05 17:24:32

标签: asp.net ajax

您好 我在使用Ajax Call的Asp.net中遇到会话时间问题。 一旦会话超时,当一个控件调用异步时,这不是 重定向到登录页面。(我正在使用表单身份验证)

在同一页面中,如果我试图在会话过期时将(在Preinit中)重定向到登录页面.., 登录页面与上一页一起出现(因为ajax调用)。

请在会话超时和进行ajax调用时让我知道重定向到登录页面的方法。

1 个答案:

答案 0 :(得分:0)

asp.net ajax有一个内置服务来帮助您进行身份验证授权

Sys.Services.AuthenticationService.logout(redirectUrl, logoutCompletedCallback, failedCallback, userContext);

要使用此服务,请将此添加到web.config

<system.web.extensions> 
    <scripting> 
        <webServices> 
            <authenticationService enabled="true" /> 
        </webServices> 
     </scripting> 
 </system.web.extensions>

http://www.asp.net/ajaxlibrary/Reference.Sys-Services-AuthenticationService-logout-Method.ashx

http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-authentication-and-profile-application-services

相关问题