RequestId Method
Returns the current request id.
Definition
// For ASP.NET Framework public static string RequestId() // For ASP.NET Core public static string RequestId(this HttpContext httpContext)
Return Value
A string identifying the current request.
Remarks
This method returns the request id of the current request (details). Including this string in your server side log entries allows you to track which log entries belong to the same request (how).
Each time you call this method within the same request, you will get the same string.
Note that if you call the jl-javascript-logger-definitions tag helper with your own request id, that doesn't mean the RequestId method from that point on returns your request id. RequestId always returns the same request id.
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.
JSNLog looks at the TraceIdentifier property of the HttpContext to get the request id.
If the method can't get the request id with the above means, it generates a random GUID.