Retrieving data from a server without increasing session timeout

Are there any ways in ASP.net to retrieve data from the server without increasing the session timeout? This needs to be done every few minutes without user interaction until the page is closed.

Additional context, upon request:

The pages in my web browser should poll the server every few minutes to check for a specific condition (emergency maintenance is scheduled for 30 minutes, in this case). When the condition is true, the page displays a message to the user. When the condition is false, nothing should happen.

As I understand it, it returns to the server reset the time until the end of the session. We do not want the session to be expanded / updated / reset / no matter what word every time the server polls page. I need a way to poll the server automatically without restarting the session timeout.

Thanks.

+8
session-timeout
source share
3 answers

If you are asking in the context of a long HTTP request so that you want to prevent HTTP <httpRuntime executionTimeout="99999"></httpRuntime> , look at web.config <httpRuntime executionTimeout="99999"></httpRuntime> where executeTimeout in seconds, I think http: // msdn.microsoft.com/en-us/library/e1f13641(v=vs.71).aspx .

If this is really just a problem with the session timeout, is it possible to ping the server asynchronously under the same user session while the lengthy process is running?

Edit : Based on your editing, if you split the Website Maintenance web service into a service outside the session state area of ​​the regular part of the site, you can call it as often as you would like. If you are currently using the ASMX web service on your current website, for example, just split it into a separate application, perhaps as a directory outside your application, so that it falls under the same domain. I think it will be good.

I'm not sure what type of web service you are calling at this time (ASMX, WCF, etc.), or even if the web service you are calling at this time is in the same application as your ASPX page applications.

+3
source share

Firstly, if the request is executed outside of the session time, a serious problem arises with the request. I would prefer to fix the request first. However, if you still want to do this using a session, try the following:

You can have Dummy.aspx in your application, and then the image element update its URL every 15 minutes, for example:

 <img id="dummyImage" src="/Dummy.aspx" width=0 height=0/> <script type="text/javascript"> var dummyImage = document.getElementById("dummyImage"); setInterval(function(){ dummyImage.src = "Dummy.aspx?_tmp=" + (Math.random() * 100000); }, 900000); </script> 

This way you will not affect the session timeout globally.

+1
source share

Use a javascript timer that starts an AJAX call. So in your PageLoad event PageLoad highlight the javascript setInterval(functiontocall(), timetowait); . The method call will be an AJAX hit by the web service that executes your request.

This will continue until the user closes the page.

Sessions are not updated from AJAX hits.

-2
source share

Source: https://habr.com/ru/post/651042/


All Articles