I have a small 4-page application for my customers to work through. They fill out information. If they let it sit too long, and the Session timeout out, I want to pop up a javascript alert that their session has expired, and that they need to start over. At that point, then redirected to the beginning page of the application.
I'm getting some strange behavior. I'm stepping through code, forcing my Sessioni.IsNewSession to be true. At this point, I write out a call to Javascript to a Literal Control placed at the bottom of the . The javascript is called, and the redirection occurs.
However, what is happening is.. I am pressing a button which is more or less a "Next Page" button and triggering this code. The next page is being displayed, and then the Alert and redirection occurs. The result I was expecting was to stay on the same page I received the "Timeout", with the alert to pop-up over it, then redirection.
I'm checking for Session.IsNewSession in a BaseClass for these pages, overriding the OnInit event.
Any ideas why I am getting this behavior?
Thanks!
There multiple ways u can do this. Have hava Script timer as per u session timeout (Default is 20 min). After 19 min just rasise a alert on client and submit the page to the same page to refresh. This may not good option given user would have entered lot of stuff already
Or other way is don't session time out this page. U can do this on back ground just refresh the page after 19 min (U can do this by placing one div and iframe or image request on the server.). This might be good experiance for the user the reason is he don't have to enter the content again. Talking to u client giving this kind of option is worth sometimes.
Related
I have no idea what this design call.
I have a page A, with a Link in it.
Click on the link, will open page B in NEW WINDOW/NEW TAB.
Page A now shows a 'Waiting for Page B' message.
input data in page B, click save, and close page B.
page A will notice that page B is closed, and display the input from page B.
I think there is some trigger in page B's unload event, but how does page A notice page B is closed?
Any idea anyone?
To make a long story short, you basically need to rely on some server-side operation to manage the "state" between these two pages.
There are a lot of approaches to be taken here, but ultimately, they are going to rely on some form of client-side polling, as an asynchronous event fired from Page B (like your 'Save' operation) won't inherently have the ability to modify the state of Page A upon returning.
Implement a timer in JavaScript to check a server value every few seconds from Page A, and make sure the 'Save' operation from Page B sets that particular condition on the server when it executes. Page A will detect it and can transition state.
Try window.postMessage.
My application is in Asp.net coded C#.
My requirement :
If someone has opened his page and didn't do nothing, then after 5 minutes the page will be closed and the changes will saved.
(this feature is exists in bank pages or another pages with protection)
Suggest how can i achieve the needed result.
You will need to use some client-side scripting to accomplish this. In your script you will need to use: setTimeout to set a timer to go off after 5 minutes of inactivity. (The timer should get reset whenever the user is actively doing something). When the timer goes off, call a function to postback to do a "save and exit".
Like #CodeOfChaos says Javascript might not let you close the browser. In my opinion it would be better to redirect the inactive user to a page telling them "Your changes have been automatically saved and you have been logged out."
I have a requirement to call a save method, that persists a model/object in the session, when the user leaves the page.
The page has various links that do not raise a postback but just perform a redirect. Are there any ASP.Net page life cycle methods I can hook into to perform the save without requiring a postback?
One solution could be to perform an asynchronous POST request (without waiting for a response) when the window is being unloaded:
An example using jQuery:
$(window).unload(function() {
$.post(location.href, $(document.forms[0]).serialize());
});
Although you will probably need to use a slightly different method for Chrome (found on jQuery forums):
It looks like the only way to get the
Ajax request to go through in Chrome
is to use the non-standard event
onbeforeunload. Chrome evidently
doesn't wait long enough to send the
Ajax request using onunload. It does
however wait for alerts...
Well that depends.
If you need to save values when the person leaves the page, then thats kinda hard.
What you can do, is to wrap all your links in some jquery, that says like:
Issue a Ajax Call, to AjaxSave.aspx, then it is completed, then window.location to the links href attribute.
BUT, that will only work if the person clicks on your links, not if the person just closes the browser or something.
You can also take the route to just save the stuff offen, so every time the person issues a post back, you just put the stuff in session. But that will mean that values changed from the last postback to the navigating away from the page is lost - don't know if that is an issue.
The last thing is to do like StackOverflow is doing. If you are editing stuff, it will show a warning when you leave the page, and then you have to click okay, to navigate away from the site.
We have inherited an ASP.Net site with two search forms on it, one with validation, one without. Each form has its own button -and its own events.
When the page is left open (idle) for about 20 minutes and then submitted using the form without any validation, the page posts back but the events aren't fired. I know that the page is posting back because I've checked that Page.IsPostBack == true.
What's curious about this is that the Page Validators are fired (even though the button clicked has CausesValidation=false) and the page appears to just be refreshed. To me, the fact that it happens after 20 minutes makes me think it's tied into the session timeout and although I could just extend the session timeout (or create a keep-alive/ping system), I would have thought there's a more practical solution to this issue.
Has anyone else come across this issue before and if so, how did you resolve it?
Yep I was right, we implemented a quick fix to move viewstate into session which is usually fine but because the session was timing out, ViewState was lost and then the events didn't know where to fire.
My question is - what is the difference between page refresh (if I press f5) and postback (If I press a button)?
Can anyone please tell me?
Thanks in advance.
A refresh mean a complete reload of the page, without any form data. This is essentially an HTTP GET.
A post back is when the page is posted to itself (through the form action=""). This is essentially an HTTP POST.
Lets have the actual difference between refresh and explicitily submitting a page :
1) Refresh does not mean to post back the page with get method..(You can check it with response.write request.form("some input type")).
2)Difference lies with the data sent to the server :
in case of explicit submit form is submitted with latest value(i.e it recognize the changes in form elements)
But in case of refresh, form is submitted with default form value.(i.e if you change the value of form element it will not reflect at server.)
when page is refresh that means page is sending request to server without any data that means HTTP GET but in another case suppose a event is fired that causes postback after
page completely load on browser if we press f5 or do refresh then it will send privious data with request instance, that means again for that data server will perform operation...
have u seen somtimes while you are doing online sopping after selecting item and press accepet button uyou get total price ,now again if you refresh then for that selected item it will again go to server that means you are buying same things twice.....i think now you get everything what i want to say...
in when page is postback then code of that page again compile and also processing `request data`. this process will going on