Reputation: 23
Is it possible to retrieve the date/time of a request in ASP.NET (preferably VB.NET)?
I have tried HttpContext.Current.Request.Headers.Get("date")
, but it returns nothing (null).
Upvotes: 1
Views: 6618
Reputation: 3937
Well, HttpContext.Current.Timestamp claims to do just that. But i'm not 100% when it grabs that timestamp.
Upvotes: 0
Reputation: 5903
According to w3c there is no "Date" header in HTTP request (but there is one in HTTP response), so you can only determine when ASP.NET've recived paticular request, but not when it was send. If you need time of receiving of a HTTP request you can use DateTime.Now, but how to do this in the best way I can answer only if you will describe you task with more details.
Upvotes: 2
Reputation: 115779
Well, DateTime.Now
will do the job in most circumstances. If you want to know date and time on client machine, you can approximate that by adding/subtracting clients' timezone offset.
Upvotes: 1