0

In Javascript, setTimeout("asd()",1000) it timeout after 1000 seconds while timeout in sessionState of webconfig uses minutes.

Does these two have the same function as in when it goes into a new page, no matter how long it takes to generate the page, it will start counting whenever it goes into the page?

In javascript, i put it under an in the html page. So does it start counting timeout when the label is loaded?

Then what about the setting in the webconfig, how it starts counting timeout?

whoami
  • 173
  • 3
  • 15

1 Answers1

1

These two are used for totally different purposes.

  • setTimeout - when executed on the client side, will call the given function after specified number of milliseconds. More on this here - https://www.w3schools.com/jsref/met_win_settimeout.asp. The countdown starts when the function is executed.
  • sessionState in webconfig is for how long the server will maintain user session. The countdown starts after server creates a user session

Hope this helps.

vabii
  • 521
  • 6
  • 16
  • what if i were to go into next page that doesn't has any timeout, while "waiting for host", the current page reached its timeout. Then will it go into the next page, or go into timeout session? – whoami May 25 '17 at 15:26
  • Not sure what you mean by 'the current page reached its timeout'. There can be multiple timeouts. If your server is not responding, there can be http connection timeout. If sessionState timeout is over, it depends upon how your application (server side) is coded when there is no user session - it might redirect to login page. These two have nothing to do with setTimeout. It is just a function to manage logic on you client side. – vabii May 25 '17 at 15:36
  • 'the current page reached its timeout' is the one using javascript. from onload untill it waits for locallhost to respond, does it continue counting when it is waiting or localhost and stops only if the next page is loaded? – whoami May 25 '17 at 15:38
  • Okay. The timeout on setTimeout() starts when browser execute that function. So, if your localhost hasn't sent any content (waiting for localhost to respond), there is nothing for browser to execute. Once you start receiving content from server, the browser will start executing (it hoist also before execution), so now whether the timeout start depends upon where on page you have defined it. Take a look at here - Order of execution - https://stackoverflow.com/questions/1795438/load-and-execution-sequence-of-a-web-page – vabii May 25 '17 at 15:48
  • i don quite understand, from page 1 to page 2. before going into page 2, waiting for localhost means I already left page 1? – whoami May 25 '17 at 16:06
  • Yes, but you are waiting for content for page 2 at this point. So the browser is reloading all resources again so it won't run your setTimeout from page 1. This is same as you are you are waiting for setTimeout on page 1 but before the timeout completes, you refresh the page. – vabii May 25 '17 at 16:17
  • so basically waiting for localhost will have nothing inside, not running anything, only waiting for page 2 to be ready? – whoami May 25 '17 at 16:25
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/145147/discussion-between-vabii-and-whoami). – vabii May 25 '17 at 16:31