当会话到期时,将Web服务重定向到登录页面 [英] redirect web service to login page when session expires asp net

查看:112
本文介绍了当会话到期时,将Web服务重定向到登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery来调用Web服务。如果会话过期,我想重定向到登录页面。我可以这样做.im允许访问经过身份验证的用户到特定文件夹。

i am using jquery to call a web service . i want to redirect to login page if session expired .how can i do it .i m allow access to authenticated user to a specific folder.

<location path="UserArea">
  <system.web>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</location>



这对于Web服务plz帮助不起作用。

.
this does not work for Web service plz help.

推荐答案

查看以下Jquery AJAX示例:



Look at the following Jquery AJAX example:


.ajax({
// ...
成功: function (data,textStatus,xhr){
console .log(xhr.status);
},
完成: function (xhr,textStatus){
console .log中(xhr.status);
}
});
.ajax({ //... success: function(data, textStatus, xhr) { console.log(xhr.status); }, complete: function(xhr, textStatus) { console.log(xhr.status); } });





这是基于一些假设和一点经验。但是......



xhr 对象有一个状态代码。通常,当您从服务器获得重定向时,这将反映在返回的状态代码中。



3xx



300代码系列处理您的重定向。如果您收到其中一个代码,则向用户显示登录页面。



您的实施可能会有所不同。您需要查看 xhr 对象以获得良好响应和错误响应。在会话到期后得到错误响应时,查找实现中的不同内容,并将其用作向用户显示登录页面的指针。



This is based on a few assumptions and a little experience. But...

The xhr object has a status code. Normally when you get a redirect from the server this will be reflected in the status code returned.

3xx

The 300 code series handle your redirects. If you get one of these codes back then show the user the login page.

Your implementation may be different. You need to look at the xhr object for good response and a bad response. Find what's different in your implementation when you get a bad response after a session expiry and use this as the pointer to show the user the login page.


这篇关于当会话到期时,将Web服务重定向到登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆