In our MVC 5 site, no session, we need to get/generate a unique ID per request. THhis will be used as an ID for logging all activity in the request.
Is there a way to as
If you need a single value without having to implement something like Guid.NewGuid()
, perhaps the HttpContext
timestamp will work for you.
int requestId = System.Web.HttpContext.Current.Timestamp.Ticks;
A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond, or 10 million ticks in a second.
Then this solution should be evaluated according to their circumstances because there is the possibility that two requests fall on the same tick of time.