Increase ASP.NET page timeout - asp.net

I have a long running method which can take a minute. On my local, it's OK, but on the server, I get a 504 response. I assume this means the page is timing out. Is it SessionState that I need to change in the web.config? I tried that but didn't help.
What's the property to increase page timeout?
Thank you.

This should solve your problem. In the web.config put
<location path="somefile.aspx">
<system.web>
<httpRuntime executionTimeout="180"/>
</system.web>
</location>
Here is the source

You can take advantage of the HttpRuntime settings. I believe in your case you would tweak the executionTimeout property (which by default I believe is 90 seconds).
Here's a full rundown on the HttpRuntime settings: HttpRuntime Element (ASP.Net Settings Schema)
<configuration>
<system.web>
<httpRuntime maxRequestLength="4000"
enable = "True"
requestLengthDiskThreshold="512"
useFullyQualifiedRedirectUrl="True"
executionTimeout="90"
versionHeader="1.1.4128"/>
</system.web>
</configuration>

No, it has nothing to do with Session. It has to do with the Request Timeout. One thing that might work is to have this on your Web.config:
<httpRuntime executionTimeout="600" /> <!-value is in secs-->

Related

Turn on and off Session in ASP.NET

Is there a way of turning on and off the session cookie in ASP.NET without using the <#PAGE construct? A way to overrule the construct?
I want sometimes to have session enabled on the page, sometimes disabled. I don't want to have to keep recompiling the website to enable or disable the session. In php you could turn on session by open_session() , I wonder if there's an asp.net equivalent. I'm looking for a way to enable the session in code.
If someone visits the Login page, the session is then enabled for the whole otherwise, it is not enabled and the site is sessionless, cookieless.
You must set the Off mode in the sessionState of the web.config file, in this way it disable the session of the application but if you want to disable the asp.net cookie but still track of the session you could use the cookielessoption.
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<sessionState mode="Off"/>
<!-- or -->
<sessionState cookieless="true"/>
</system.web>
</configuration>
Guess you can do it in web.config: https://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.71).aspx

session in asp.net is getting close after 2-3 minutes

I have made a web application which uses user authentication and if user is authenticated user then i store it in Session like below.
Session("uid") = txtUid.text
But after 2-3 minutes Session is automatically cleared.
increase your session time in Web.config
<system.web>
<sessionState timeout="260" />
</system.web>
2 - 3 minutes?
it means that you are not sure how long it takes for the session to close.
from here i can assume that you are using internet explorer?
internet explorer has a known issue with asp.net, if you have an underscore in your virtual path like
www.mySite.com/some_test_site.aspx
so i bet you have a scenario like this.
in any case, you can add the following line to your web.config to keep vars for 60 minutes:
<sessionState mode="InProc" timeout="60"/>
it goes under:
<configuration>
<system.web>
You can set the session state of your web application in web.config. Add this code in the Configuration section of your web.config.
<configuration>
<system.web>
...
<sessionState timeout="20" />
...
</system.web>
</configuration>

ASP.NET Uploading file over 300KB~ makes browser lose connection

I've been running my image-uploading site for about a month now. I haven't touched the script lately and this problem that occurs now never happened before, with even bigger uploads.
When uploading a file with a size that exceeds the 300 KB area, your browser would lose connection. Anything lower than that would upload immediatly, you hit the upload button in no moments you're redirected to the page of your image.
The website address is http://img.kfirprods.com/Upload.aspx
As for my web.config, I tried all these suggestions to change execution time and maxRequestLength but none of these helped, with both modest sizes and unmodest sizes. The default settings for the requestLength is about 4MB and the user-server connection is lost way before that. This is my web.config
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime requestValidationMode="2.0" />
<customErrors mode="Off"/>
<machineKey
validationKey="EEF33150A048D162D22CB36E1CB9956B148C7A4E6999D0F05B53D416D7A16F83823DD626F501DD3549D3E5DCB473634739D0AD9A07F71560946498C943A7586D"
decryptionKey="0E95F75864047EB6322EA7D5246F2C1175D77A1B016F293C3BAAD000299A3DC8"
validation="SHA1"
decryption="AES" />
</system.web>
</configuration>
There were others httpRuntime settings but even the default settings, which should work - don't. However, what exactly happens is that the server behaves as if it's down but it will only be down to the user who exceeded that small size of upload and return after a minute or two. Please, anyone who's even a bit of an expert - try to upload some 'heavy' picture and see if you recognize the problem.
Put following in your web.config file
<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" />
</system.web>
</configuration>
by default the value is 4096 = 4mb. However, on shared hosting individual hosts might configure a different value and it limits the size of file that you can upload.
Further, you can/cannot modify these settings depending on the permissions given by your host.
Please set Server.ScriptTimeout to longer value like
Server.ScriptTimeout=36000
with adding
<httpRuntime maxRequestLength="9999" />
setting in webconfig. Please let me know if this does not work
The uploading limit of ASP.NET FileUploader is 4MB. But you can increase the limit of length of uploaded file by adding the following code into your web.config:
<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" />
</system.web>
</configuration>
It's also a good idea to ADD executiontimeout
<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" executiontimeout="700" />
</system.web>
</configuration>
I will ask the host provider (HostGator) if they know anything about it, again (the first customer support guy didn't seem to know much at all). If it won't work, I might as well give up, it's not like there are not enough image uploading websites on the web. Thanks for those who tried to help!

Moved from iis6 to 7.5 asp.net session timeouts

After moving over to the new platform the site is logging people out after a time of inactivity. This never used to happen and I wish to set the timeout to a larger value. I've changed some settings to no effect and even in code the session.timeout is set to 1440.
Any ideas where I can find another setting for it or where I might start with this problem.
Thanks
The app pool was recycling as the worker process was set to expire after 20 minutes of inactivity.
Have a look at IIS session information here: HttpSessionState.Timeout Property
<configuration>
<system.web>
<sessionState
mode="InProc"
cookieless="true"
timeout="30" />
</system.web>
</configuration>
You can add this section to your web.config in your website root dir for authentication:
<system.web>
<authentication mode="Forms">
<forms timeout="1440" slidingExpiration="true"/>
</authentication>
</system.web>
Assuming that you're using Forms authentication.
And this for session timeout:
<system.web>
<sessionState timeout="1440"/>
<system.web>

Session Timeout extend in Asp.Net

How to extend the session timeout?
I tried entering:
Session.Timeout = 720;
In formLoad and also tried in webconfig:
<system.web>
<sessionState
mode="InProc"
cookieless="true"
timeout="720" />
</system.web>
But still it times out after 10 minutes. Can anyone help about this issue?
Take a look at this Microsoft Technet article. Check if it suits your needs.
<configuration>
<system.web>
<sessionState
cookieless="true"
timeout="20">
</sessionState>
</system.web>
</configuration>
You might see this article, I haven't used it but a time ago I needed something like this to use in a webservice and I finished with another approach. It could be useful to you:
The Defibrillator: Keeping ASP.NET Session Alive Ad Infinitum

Resources