How to increase time out of webform webmethod request in asp.net webforms? - asp.net

I am using webform c#, here one of my method is taking about 3-4 minutes to execute completely method runs absolutely fine in developing environment but when publish put it on IIS it produces error of time out. i have tried with both ajax and server side button click event both but got same issue. I have also tried to increase the connection time out setting from IIS, it also doesn't work. on project webconfig I have changed these lines, not worked.
<system.web>
<httpRuntime executionTimeout="180" />
</system.web>
Is there any other way or I am missing any thing something? My IIS version is 10

In Web.config executionTimeout setting in seconds. so as per your details it's taking 3-4 minutes. so you need to set it as per that. like. executionTimeout="600" (600 sec : 5 minute)
And instead of globally increases the timeout of all pages you can also be applied for specific pages in the following way.
<location path="yourpagename.aspx">
<system.web>
<httpRuntime executionTimeout="900"/>
</system.web>
</location>

Related

windows authentication error (only with a lot of data)

I have an ASP.net website running under IIS6. In one .aspx page the user has to enter data which is then stored into a database. The amount of data can vary. The project uses Windows Authentication.
So far everything worked, but once the data exceeds a certain amount, the website asks again for the credentials. When I click cancel a 401 error is returned, when I enter username/password a 12152 error (after some time of processing). I have tried it with IE6 and IE9 (also in IE8 mode).
Any ideas what could be done?
Sounds like an execution timeout, the default is 110 seconds. Try changing the executionTimeout and maxRequestLength attributes of the httpRuntime configuration.
<httpRuntime executionTimeout="1200" maxRequestLength="104856" />
After more than one month I was finally able to solve it: I had to increase the MaxHttpCollectionKeys-settings in the web.config file.
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>
After this modification the error was gone.

Large file uploading

I want to upload a large file in asp.net app of visual studio 2010. But I have got connection reset error. How can I solve it? Thanks.
P.S I have changed the requestlimited in the webconfig which is not to be make any effect.
It's a security setting to limit the size of the request. It's a setting called RequestMaxLength in web config. I believe the default is 3 or 4 MB... An asp.net file upload will be limited by the number defined in this setting (any request for that matter).
<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" executionTimeout="1200" />
</system.web>
</configuration>
It's not wise to make this a very large number because it exposes you to DOS attack since someone could just flood your server with huge files. There is also an executionTimeout property that might have to be set as well

Severe Session issues ASP.NET

I have a kind of an ugly situation.
I have a big program that uses session to carry over data from one page to another in a CRM system build in ASP.NET 3.5 C#
The problem is that if you have two instance of this program open in the same browser and browse the same page, the sessions of course gets overridden.
As you can imagine, this is a huge issue and a huge liability for the system.
What is the right thing to do here? I use tons of AJAX, and need to pass objects from page to page, so url parameters is not really an option here.
Any suggestions?
What is your web.config sessionState configured? I think in your situation you can reduce the severity of your problem by configuring it as follows:
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="true" timeout="20"/>
OR
<sessionState cookieless="true" regenerateExpiredSessionId="true" timeout="20" />
</system.web>
</configuration>
But the latter is going to mangle your URLs. You'll end up with ASP.NET inserting session IDs into your URLs, something like http://www.example.com/(S(lit3py55t21z5v55vlm25s55))/orderform.aspx. More about it here.

IIS Request Timeout on long ASP.NET operation

I am experiencing a request timeout from IIS when I run a long operation. Behind the scene my ASP.NET application is processing data, but the number of records being processed is large, and thus the operation is taking a long time.
However, I think IIS times out the session. Is this a problem with IIS or ASP.NET session?
If you want to extend the amount of time permitted for an ASP.NET script to execute then increase the Server.ScriptTimeout value. The default is 90 seconds for .NET 1.x and 110 seconds for .NET 2.0 and later.
For example:
// Increase script timeout for current page to five minutes
Server.ScriptTimeout = 300;
This value can also be configured in your web.config file in the httpRuntime configuration element:
<!-- Increase script timeout to five minutes -->
<httpRuntime executionTimeout="300"
... other configuration attributes ...
/>
Please note according to the MSDN documentation:
"This time-out applies only if the debug attribute in the compilation
element is False. Therefore, if the debug attribute is True, you do
not have to set this attribute to a large value in order to avoid
application shutdown while you are debugging."
If you've already done this but are finding that your session is expiring then increase the
ASP.NET HttpSessionState.Timeout value:
For example:
// Increase session timeout to thirty minutes
Session.Timeout = 30;
This value can also be configured in your web.config file in the sessionState configuration element:
<configuration>
<system.web>
<sessionState
mode="InProc"
cookieless="true"
timeout="30" />
</system.web>
</configuration>
If your script is taking several minutes to execute and there are many concurrent users then consider changing the page to an Asynchronous Page. This will increase the scalability of your application.
The other alternative, if you have administrator access to the server, is to consider this long running operation as a candidate for implementing as a scheduled task or a windows service.
Great and exhaustive answerby #Kev!
Since I did long processing only in one admin page in a WebForms application I used the code option. But to allow a temporary quick fix on production I used the config version in a <location> tag in web.config. This way my admin/processing page got enough time, while pages for end users and such kept their old time out behaviour.
Below I gave the config for you Googlers needing the same quick fix. You should ofcourse use other values than my '4 hour' example, but DO note that the session timeOut is in minutes, while the request executionTimeout is in seconds!
And - since it's 2015 already - for a NON- quickfix you should use .Net 4.5's async/await now if at all possible, instead of the .NET 2.0's ASYNC page that was state of the art when KEV answered in 2010 :).
<configuration>
...
<compilation debug="false" ...>
... other stuff ..
<location path="~/Admin/SomePage.aspx">
<system.web>
<sessionState timeout="240" />
<httpRuntime executionTimeout="14400" />
</system.web>
</location>
...
</configuration>
I'm posting this here, because I've spent like 3 and 4 hours on it, and I've only found answers like those one above, that say do add the executionTime, but it doesn't solve the problem in the case that you're using ASP .NET Core. For it, this would work:
At web.config file, add the requestTimeout attribute at aspNetCore node.
<system.webServer>
<aspNetCore requestTimeout="00:10:00" ... (other configs goes here) />
</system.webServer>
In this example, I'm setting the value for 10 minutes.
Reference: https://learn.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module#configuring-the-asp-net-core-module
Remove ~ character in location
so
path="~/Admin/SomePage.aspx"
becomes
path="Admin/SomePage.aspx"

ASP.NET MVC FormsAuthentication Cookie timeout cannot be increased

Using the default ASP.NET MVC template, I cannot figure out how to increase the FormsAuthentication timeout. It seems to always use 30 minutes.
I have followed Scott Gu's recommendation from this blog post, but it does not seem to make a difference. Does anyone have a suggestion?
His suggestion was to set the timeout value in the web.config file:
<system.web>
<authentication mode="Forms">
<forms timeout="2880"/>
</authentication>
</system.web>
My issue was only occurring in my production environment at my web host.
I found this link and generated a machine key to put in the web.config. Once I did that, the timeout value took effect.
I had the same problem and adding a custom MachineKey with a ValidationKey to the web.config solved the problem. It seems to affect shared hosts.
I used this site to generate a random machine key:
http://aspnetresources.com/tools/machineKey
Be sure that you are setting this in the ~/Web.config file and not in the ~/Views/Web.config file. Also, 50 million minutes is approx. 100 years, which might be hitting some date-related overflow in the browser. Try using a more reasonable number like 2 - 3 years (1.5 million minutes).

Resources