I have a handler that return a json,
I some cases I execute more manipulations with data that increase execution time (10 min for example)
I want to increase timeout (to avoid 504 Gateway Timeout ) for this handler, I tried to add in web.config global executionTimeout
<system.web>
<!-- Set timeout 10 minutes -->
<httpRuntime executionTimeout="600"/>
</system.web>
directly to my handler name
<location path="myHandler.ashx">
<system.web>
<httpRuntime executionTimeout="600"/>
</system.web>
</location>
Inside the handler in ProcessRequest
context.Server.ScriptTimeout = 600000;
no one of above solutions not resolve 504 error code
WS 2012 R2, IIS 8.5
In postman Time-out is after 45020 - 45050 ms (~45 sec)
Related
I'm trying to increase maximum upload limit size in my .NET application... Current one is 4MB and I'd like to increase it to 25 MB ...
What I have tried so far (modifying web.config file):
<security>
<requestFiltering>
<!-- maxAllowedContentLength, for IIS, in bytes -->
<requestLimits maxAllowedContentLength="15728640" ></requestLimits>
</requestFiltering>
</security>
And:
<system.web>
<httpRuntime maxRequestLength="25000" />
</system.web>
The second method gives me following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Without any of these method I'm getting this error:
Maximum request length exceeded.
I'm using .NET Web Forms... And my IIS version is 8 (or above I believe)...
Can someone help me out with this ?
string fileName = fileLanguage.PostedFile.FileName;
using (var fileStream = File.Create(Server.MapPath("../languages/") + fileName))
{
fileLanguage.PostedFile.InputStream.Seek(0, SeekOrigin.Begin);
fileLanguage.PostedFile.InputStream.CopyTo(fileStream);
}
Language language = new Language();
language.Name = txtLanguageName.Text;
language.Path = fileName;
ServiceClass.InsertLanguage(language);
I've found the reason why the method #2 didn't work... Turns out I had a folder from which I was uploading the files?? And that folder had its own config inside it self... All I had to do was to insert this into my folder's web.config file like following:
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="?"/>
</authorization>
<httpRuntime executionTimeout="100000" maxRequestLength="214748364" />
</system.web>
</configuration>
Note you can limit the file size to something about ~25-30 MB, since it's not recommended to allow users or anyone else to upload large files onto your server.
Cheers!
I'm working on asp.net project. how can I increase the session timeout? (infinity timeout)
Or should I do this on IIS? If it is possible, please explain.
You can set session timeout in web.config as shown below. The value is showing minutes, so you can set as long as you want, up until a year.
<configuration>
<system.web>
<sessionState timeout="200"></sessionState>
</system.web>
</configuration>
The Timeout property can be set in the Web.config file for an
application using the timeout attribute of the sessionState
configuration element, or you can set the Timeout property value
directly using application code.
The Timeout property cannot be set to a value greater than 525,600
minutes (1 year). The default value is 20 minutes.
You cannot assign it to unlimited. You can increase the value in minutes using the time out attribute of Session state element in web.config
<sessionState timeout="30">
</sessionState>
By default session timeout value is 20 minutes. Also in your case if you are using forms authentication, check the authentication time out value as well
<authentication mode="Forms">
<forms loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication>
one way is by setting the timeout in web.config file. Like
<configuration>
<system.web>
<sessionState mode="InProc" timeout="120"/>
</system.web>
</configuration>
The other way is by setting the time-out in server side code in .cs file. Like
Session.Timeout = 100;
The time-out value entered will be read as minutes. If set to 0, then there will be an error page displaying session time-out value cannot be 0 and must be >0.
I have a problem in creating Session. Session.Timeout doesn't work.
This is my code
Session["UID"] = Uid;
Session["UserName"] = UserName;
Session.Timeout = 10; // ?not responding
Session.Timeout occurs after 3 or 4 minutes
You should set session timeout in the web.config file like this:
<sessionState
mode="InProc"
cookieless="AutoDetect"
timeout="10" />
Taken from here: MSDN on the session state element in web.config
try b making changes in your web.config file instead of the cs file.
<configuration>
<system.web>
<sessionState
mode="InProc"
cookieless="true"
timeout="30" />
</system.web>
</configuration>
read more about it at MSDN
I have an asp.net app with master pages. I need to have a session timeout after 10 minutes, for which I have a javascript code block. Is there any other more efficient way to do a session timeout rather than have a javascript code block on every page? (I am not using membership provider).
You can change the timeout of your session in your web.config
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
stateNetworkTimeout="10"
sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"
sqlCommandTimeout="30"
customProvider=""
cookieless="UseCookies"
cookieName="ASP.NET_SessionId"
timeout="10"
allowCustomSqlDatabase="false"
regenerateExpiredSessionId="true"
partitionResolverType=""
useHostingIdentity="true">
<providers>
<clear />
</providers>
</sessionState>
reference:http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.80).aspx
you can simply do this on server side. there is no point to time your session on client side. in that case, you can do it centrally on master page or webconfig or global.asax.
Using javascript is a bad idea, you can do what you want easily on the server.
Add this to your Global.asax
protected void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 10;
}
And this to your web.config
<configuration>
<system.web>
<sessionState timeout="10"></sessionState>
</system.web>
</configuration>
You need to add both to make it work effectively.
You can made changes in web.config file by adding following to have session timeout:
<system.web>
<authentication mode="Forms">
<forms timeout="10"/>
</authentication>
<sessionState timeout="10" />
</system.web>
You can do it from c# by using following code:
Session.Timeout = 10;
How I can set the timeout for a session specific in ASP.NET? it is possible?
I have two or more sesions in my web application, I need set:
Session["foo"] //expire in 14minutes
Session["baa"] //expire in 30minutes
I'm wanting solve this case,if possible not using cookies.
Thanks in advance!
You can configure the timeout for a session in the Web.config file:
<configuration>
<sessionstate mode="inproc"
cookieless="true"
timeout="14" />
</configuration>
This is the default mode (InProc) for ASP.NET. As rockinthesixtring said in his comment, you can't configure the timeout for individual objects in the session, just the session as a whole.
ASP.NET Session State Overview
for specific session
lets say you want to make timeout for this session Session["foo"] =14 min
you can do like this
DateTime timenow=DateTime.now;
DateTime timeafter14min=timenow.AddMinuits(14);
if(DateTime.Now>timeafter14min)
{
HttpContext.Current.Session["foo"]=null;
}
session not expired but cleared
<sessionState
mode="InProc"
stateNetworkTimeout="10" //seconds
cookieless="UseCookies"
cookieName="ASP.NET_SessionId" //Specifies the name of the cookie that stores the session identifier.
timeout="20" //seconds
regenerateExpiredSessionId="true"
useHostingIdentity="true">
</sessionState>
or
session["user"]=textbox_username.txt
<configuration>
<system.web>
<sessionState cookieless="true"
regenerateExpiredSessionId="true" />
</system.web>
</configuration>
Since other questions are being closed as duplicates of this question I would like to add this option here for people who may find it useful.
You can set the Session Timeout manually using the following:
Session.Timeout = 60
You can read more here:
https://msdn.microsoft.com/en-us/library/ms525473(v=vs.90).aspx