TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aakash N
NA
166
19.7k
session variables-null/lost - IIS after 20-30 secs when idle
Jan 7 2019 2:33 PM
I am working on a project where we use SQL server session and set and get variables from the table. When working with Visual studio it works normal but, on IIS remote server the session variables are lost immediately if we keep application idle for 20-30 seconds.
Here is the startup.cs code:
services.AddDataProtection().SetDefaultKeyLifetime(TimeSpan.FromDays(14));
//.PersistKeysToFileSystem(new DirectoryInfo("./Keys/"));
services.AddDistributedMemoryCache();
services.AddHttpContextAccessor();
services.ConfigureApplicationCookie(options => {
options.Cookie.Expiration = TimeSpan.FromMinutes(30);
options.ExpireTimeSpan = TimeSpan.FromDays(3);
});
services.AddSession(options =>
{
options.Cookie.Name =
".app.Session"
;
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly =
true
;
options.Cookie.IsEssential =
true
;
options.Cookie.SecurePolicy = CookieSecurePolicy.None;
});
services.AddStactive();
And web.config:
<?xml version=
"1.0"
encoding=
"UTF-8"
?>
<configuration>
<system.webServer>
<handlers>
<add name=
"aspNetCore"
path=
"*"
verb=
"*"
modules=
"AspNetCoreModule"
resourceType=
"Unspecified"
/>
</handlers>
<aspNetCore processPath=
"bin\IISSupport\VSIISExeLauncher.exe"
arguments=
"-argFile IISExeLauncherArgs.txt"
stdoutLogEnabled=
"true"
stdoutLogFile=
".\logs\stdout"
forwardWindowsAuthToken=
"false"
>
<environmentVariables />
</aspNetCore>
<directoryBrowse enabled=
"true"
/>
<defaultDocument enabled=
"true"
/>
<security>
<requestFiltering allowDoubleEscaping=
"true"
/>
</security>
</system.webServer>
</configuration>
Do I need to add any extra configuration either in startup.cs or web.config to make sure session values are available until the SQL session is Timeout?
My current project is developed using ASP.NET core 2.1
Can someone help me with this situation on handling session variables on IIS servers?
Thanks!!
Reply
Answers (
4
)
When click next Button get error NullReferenceException
how to get the weatherinfo from bot online code editor