Returns the current request id.
// For ASP.NET 4.x public static string RequestId() // For ASP.NET Core public static string RequestId(this HttpContext httpContext)
A string identifying the current request.
Each time you call this method within the same request, you will get the same string.
How the request id is found
This method first checks whether the current request is a log request from the jsnlog.js library. If it is, it returns the request id contained in the log request. This way, the request ids in the client side log requests match the request id of the original request to the server that loaded the page that is now sending those log requests.
If it is not a log request, this method comes up with a unique id for the current request.
On ASP.NET 4.x, if you have Event Tracing for Windows (ETW) switched on, JSNLog uses the same request id that is used internally by IIS.
On ASP.NET Core, it looks at the TraceIdentifier property of the HttpContext.
If the method can't get the request id with the above means, it generates a random GUID.