开发者

Validate and reset system clock on ASP.NET website startup?

I have an ASP.NET application that is hosted on a farm of virtual servers with time problems. The symptoms are that when servers startup or reboot they often come up with a bad system time (potentially hours off).

(Obviously the best answer would be to solve the system problem, but that is currently beyond my control...)

So here's the question: Is there are straight forward way for me to get my ASP.NET application to query an authoritative NTP server on startup and then reset the system clock if needed?

Technical开发者_运维问答 assumptions: * ASP.NET 4.0 * Windows 2008 * Full local admin rights on server


You may be able to do this using WMI (Windows Management Instrumentation). Though I don't have personal experience with doing so, there are numerous examples out there. To start:

  1. The classes in System.Management will help you query WMI from within the .NET framework
  2. MSDN example: connecting to a remote computer to run a WMI query
  3. WMI scripts: Date/Time tasks
  4. The Win32_LocalTime class
  5. Using the WMI Update Query Language to update system information

Hope that sets you off in the right direction.


I don't think the application is the right place to be resetting system time. If I'm not mistaken, Windows Time Service can manage this:

http://www.windowsnetworking.com/articles_tutorials/configuring-windows-time-service.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜