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?
Asked
Active
Viewed 251 times
-1
-
Without showing some code to clarify what you're talking about, it will be extremely difficult to answer this question. Please read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and related topics in the help center. Thanks. – Matt Johnson-Pint Jun 21 '14 at 20:22
-
I do not work with session timeout manually. BUt I simply use asp.net membership Form authentications .So I think the code is not needed and my question is pretty clear and accurate. – Forough Jun 22 '14 at 03:33
1 Answers
0
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

marathonman
- 452
- 4
- 9
-
1If you just subtract the base offset, that won't account for time zones that use daylight saving time. Use `TimeZoneInfo.ConvertTimeFromUtc` instead. – Matt Johnson-Pint Jun 21 '14 at 20:19
-
@MattJohnson thank you for your attention and assistance. i updated my answer. at SO if someone like you give an advice, how can I give him a credit – marathonman Jun 21 '14 at 20:50
-
You just did. :) No points are necessary for advice in comments. You can upvote the comment if you think others will find it useful. – Matt Johnson-Pint Jun 21 '14 at 20:53
-
IIS restart did not help. But renaming 'web.config' or 'app_offline.htm' seems to work. I think renaming(or overwriting) bin file will work too. But for now I solved my problem with the time changing. If I stop the VMWare Tools service and set it to manual and then restart the server with corrected DateTime, Elastix will force the correct time to the VPS. Thank you all! – Forough Jun 22 '14 at 03:35