Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.
HTML
<location path="UserArea">
  <system.web>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</location>
.
this does not work for Web service plz help.
Posted
Updated 15-Oct-14 21:25pm
v2

1 solution

Look at the following Jquery AJAX example:

JavaScript
$.ajax({
    //...        
    success: function(data, textStatus, xhr) {
        console.log(xhr.status);
    },
    complete: function(xhr, textStatus) {
        console.log(xhr.status);
    } 
});


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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900