My MVC application expires after 20 minutes i.e., when i automatically select any button after 20mins If I click on the app then the app will be redirected to the login page. All buttons in my page use Ajax calls, so when we click any button, the AJAX will return a failure code and be redirected to the login page.
Problem: If I am in the middle of a page with a search criteria and paging, when I login again from time to time, then I am not able to come to the exact page where I Was the first Since I am using Ajax calls on button clicks, I can not see the search parameters or page numbers on the URL. Please help someone on this.
Timeout is returning to the following error status on Ajax and has been redirected to the login page.
Error: function (xhr, ajaxOptions, thrownError) {If (xhr.status == 401) {window.location.href = "/ home / logout"; Return; }}
You can use the History API to keep track of the exact url Where are you
Check that makes life easier:
You have to call this API when any link is clicked / button due to which you want to 'remember' AJAX call Causes. Sample from
:
function search (params) {// record your current UI status (data to save), title (to set on page) ), URL (to set the page) History.pushState ({params: params}, "search", "search"); // now whatever is happening, because client trigger search ()}
You must update the url on each action. Then, in the logoff
action, add the current URL to your logoff
URL as the ReturnUrl
parameter and it will work.
Comments
Post a Comment