We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ASP.NET Item variable from HttpContext.Items dictionary. Useful for storing state per request basis.
HttpContext.Items
Platforms Supported: All
${aspnet-item:variable=String:objectpath=String:format=String}
Introduced with NLog.Web v5.1, and replaces the Variable-option
Variable
Introduced with NLog.Web v5.0
Introduced with NLog.Web v5.2 and replaces EvaluateAsNestedProperties-option
EvaluateAsNestedProperties
You can set the value of an ASP.NET Item variable by using the following code:
Example usage of ${aspnet-item}
${aspnet-item}
HttpContext.Items["myvariable"] = 123; HttpContext.Items["stringvariable"] = "aaa BBB"; HttpContext.Items["anothervariable"] = DateTime.Now; ${aspnet-item:variable=myvariable} - produces "123" ${aspnet-item:variable=anothervariable} - produces "01/01/2006 00:00:00" ${aspnet-item:variable=anothervariable:culture=pl-PL} - produces "2006-01-01 00:00:00" ${aspnet-item:variable=myvariable:padding=5} - produces " 123" ${aspnet-item:variable=myvariable:padding=-5} - produces "123 " ${aspnet-item:variable=stringvariable:upperCase=true} - produces "AAA BBB"