How to restrart asp.net session start time on server? - asp.net

My Server (VPS) takes a DateTime about 12 hours more than now DateTime, after a system restart.(tomorrow date and toggled AM/PM time).
The issue is that when I correct the date and the time on server, I can not login to my asp application anymore! In fact the login proccess goes well but it logs out immediately. It seems that the session start time is still tomorrow(the wrong DateTime) and the sliding expiration time always compares to the current server time and causes logout.
How can i restart session start time? Which service or configuration will restart it to take the correct DateTime?

it should not changed after restart, do you share this situation with your service provider?
it's better to work with UTC times.
Dim timeZone = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time")
Dim utcNow As Date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZone)
when you change server time it will not effect your sessions. you must remove or renew your sessions.
if your problem just with sessions
Session.Clear()
Session.Abandon()
Session.RemoveAll()
also restarting application will do same thing.
you can restart your application these ways;
1
restart IIS
2
File.SetLastWriteTime(HttpContext.Current.Request.MapPath("~\Web.config"), Date.Now)
3
rename web.config file to something(like 0web.config) and after that rename it again to web.config
4
create app_offline.htm on your root folder. it will close your app. when you want go online again rename it something else like 0app_offline.htm

Related

IIS sending 1 less second in last-modified reaponse header parameter

We have an IIS server with having web service setup. When user call the web service, We are fetching a value from DATETIME field from database. It's something like
After fetching value from database, the c# code is converting it with below code
LastModified = DateTime.SpecifyKind(rs.GetDateTime(1), DateTimeKind.Utc) // Here rs.GetDateTime(1) = 2022-04-06 11:46:45.000
The code is then adding this value to the response. header.last-modified parameter. When we call this API from the client end, it shows 2022-04-06 11:46:44.000 GMT (1 less second)
Checked everything but did not find anything. Even server time is also up to date, no issues on IIS setup, timezone is UTC and seems to be synced.
Even we have the same setup on another server where its working fine without 1 less second issue.
When I run the command from the server, It's showing the correct time. That means I doubt that in between may be IIS in reducing the time by 1 second from that header parameter called last-modified.

AzerothCore Docker deployment set to America/New_York but Ingame Events still seem to use UTC

I have been trying to figure this out on my own, but it's been something that I am unable to. I'm not sure if this is an issue or just something on my end. In my Dockerfile, I changed all the instances of ENV TZ=Etc/UTC to ENV TZ=America/New_York and this works correctly for the realm time in game.
Realm Time and Local Time match
Events however, Is there some other configuration I am missing? Because, for example, the STV Finishing Event does not happen at 2PM Eastern Time, but it at 2PM UTC, so 10AM Eastern. I have not been able to do the event once by it just happening. I needed to start the event manually.
Also the evening event starts earlier. I think that is supposed to start at 6PM server time? Or the Leprithus event. I believe that one is supposed to start at 8PM.
Current events at 5:55PM Realm time
Is there another configuration file that I need to modify? It does not seem like the events are adjusting for the server's timezone.

Symfony: logout automatically in a very short period of time

Whenever a user connect to the application after a very short period of time (like 2 or 3 minutes) he gets logged out from the application.
I thought it's the session's lifetime that being very short so I have increased it in the config.yml file like this:
framework:
session:
cookie_lifetime: 7200
But still the same problem.
The application works fine on locahost but I face this when it's running remotely!
Is there anything I should be aware of to fix this issue?
Check your session.cookie_lifetime in the php.ini file of your remote server, I'm not sure but it may override the parameters in Symfony.
After you change it, don't forget to restart php so the change is taken into account.

Issue running ASPX page using Scheduled Task

I have a scheduled task set up to run Scan.aspx every 3 minutes in IE7. Scan.aspx reads data from 10 files in sequence. These files are constantly being updated. The values from the file are inserted into a database.
Sporadically, the value being read is truncated or distorted. For example, if the value in the file was "Hello World", random entries such as "Hello W", "Hel", etc. will be in the database. The timestamps on these entries appear completely random. Sometimes at 1:00 am, sometimes at 3:30 am. And some nights, this doesn't occur at all.
I'm unable to reproduce this issue when I debug the code. So I know under "normal" circumstances, the code executes correctly.
UPDATE:
Here is the aspx codebehind (in Page_Load) to read a text file (this is called for each of the 10 text files):
Dim filename As String = location
If File.Exists(filename) Then
Using MyParser As New FileIO.TextFieldParser(filename)
MyParser.TextFieldType = FileIO.FieldType.Delimited
MyParser.SetDelimiters("~")
Dim currentrow As String()
Dim valueA, valueB As String
While Not MyParser.EndOfData
Try
currentrow = MyParser.ReadFields()
valueA= currentrow(0).ToUpper
valueB = currentrow(1).ToUpper
//insert values as record into DB if does not exist already
Catch ex As Exception
End Try
End While
End Using
End If
Any ideas why this might cause issues when running multiple times throughout the day (via scheduled task)?
First implement a Logger such as Log4Net in your ASP.NET solution and Log method entry and exit points in your Scan.aspx as well as your method for updating the DB. There is a chance this may provide some hint of what is going on. You should also check the System Event Log to see if any other event is associated with your failed DB entries.
ASP.NET is not the best thing for this scenario especially when paired with a Windows scheduled task; this is not a robust design. A more robust system would run on a timer inside a Windows-Service-Application. Your code for reading the files and updating to the DB could be ported across. If you have access to the server and can install a Windows Service, make sure you also add Logging to the Windows Service too!
Make sure you read the How to Debug below
Windows Service Applications intro on MSDN: has further links to:
How to: Create Windows Services
How to: Install and Uninstall Services
How to: Start Services
How to: Debug Windows Service Applications]
Walkthrough: Creating a Windows Service
Application in the Component Designer
How to: Add Installers to Your Service Application
Regarding your follow up comment about the apparent random entries that sometimes occur at 1am and 3.30am: you should:
Investigate the IIS Log for the site when these occur and find out what hit(visited) the page at that time.
Check if there is an indexing service on the server which is visiting your aspx page.
Check if Anti-Virus software is installed and ascertain if this is visiting your aspx page or impacting the Asp.Net cache; this can cause compilation issues such as file-locks on the aspnet page in the aspnet cache; (a scenario for aspnet websites as opposed to aspnet web applications) which could give weird behavior.
Find out if the truncated entries coincide with the time that the files are updated: cross reference your db entries timestamp or logger timestamp with the time the files are updated.
Update your logger to log the entire contents of the file being read to verify you've not got a 'junk-in > junk-out' scenario. Be careful with diskspace on the server by running this for one night.
Find out when the App-Pool that your web app runs under is recycled and cross reference this with the time of your truncated entries; you can do this with web.config only via ASP.NET Health Monitoring.
Your code is written with a 'try catch' that will bury errors. If you are not going to do something useful with your caught error then do not catch it. Handle your edge cases in code, not a try catch.
See this try-catch question on this site.

IIS 7 Classic ASP session for website, website subdirectory, application inside website

Environment: Win server 2008 R2, IIS 7.5
Website:
MainWebsite
MainWebsite\Subdirectory
MainWebsite\VirtualDirectory
For MainWebsite - ASP -> (Session Properties) -> Time-Out -> 00:04:00
For MainWebsite\Subdirectory -> ASP -> (Session Properties) -> Time-Out -> 00:08:00
AppPool -> (Process Model) -> Idle Time-Out (minutes) -> 10 [I set it to 10 minute]
Requirement:
I want the MainWebsite to hold the session for 4 minutes.
I want the MainWebsite\Subdirectory to hold the session for 8 minutes.
The above configuration is kind of a tiny test I am doing, so I could replace the time-out values with 20 mintues or 30 mintues on my real prod environment.
The issue is, the Session time out setting for the "Mainwebsite\subdirectory" is not effective.
Though it is set to 8 minutes, the session is lost after every 4 minutes, where 4 minutes is the setting of the MainWebsite.
Is this the expected behaviour, then I dont understand why there is an option to configure the ASP Session Timeout on a subdirectory level.
Let me know if you need more information. Appreciate your comments.
Since this is being done in IIS it does make sense how it's working. Your timing out the whole site including the subdirectories before the subdirectory is timed out. The reason you can set it is if you want to time out the sub directory before the main level. I would recommend using asp code to timeout the session. You can set it in your global.asa so it's done at the global level for each session.
<%
Session.Timeout = 40
%>
where 40 = the number of minutes.
Reference: http://classicasp.aspfaq.com/general/how-do-i-increase-timeout-values.html

Resources