[This is preliminary documentation and is subject to change.]

ASP.NET Application variable.

Namespace:  NLog.LayoutRenderers
Assembly:  NLog (in NLog.dll) Version: 2.0.0.0

Syntax

C#
public class AspNetApplicationValueLayoutRenderer : LayoutRenderer
Visual Basic (Declaration)
Public Class AspNetApplicationValueLayoutRenderer _
	Inherits LayoutRenderer
Visual C++
public ref class AspNetApplicationValueLayoutRenderer : public LayoutRenderer

Remarks

Use this layout renderer to insert the value of the specified variable stored in the ASP.NET Application dictionary.

Examples

You can set the value of an ASP.NET Application variable by using the following code:

CopyC#
1HttpContext.Current.Application["myvariable"] = 123;
2HttpContext.Current.Application["stringvariable"] = "aaa BBB";
3HttpContext.Current.Application["anothervariable"] = DateTime.Now;

Example usage of ${aspnet-application}:

Copy 
1${aspnet-application:variable=myvariable} - produces "123"
2${aspnet-application:variable=anothervariable} - produces "01/01/2006 00:00:00"
3${aspnet-application:variable=anothervariable:culture=pl-PL} - produces "2006-01-01 00:00:00"
4${aspnet-application:variable=myvariable:padding=5} - produces "  123"
5${aspnet-application:variable=myvariable:padding=-5} - produces "123  "
6${aspnet-application:variable=stringvariable:upperCase=true} - produces "AAA BBB"

Inheritance Hierarchy

System..::.Object
  NLog.LayoutRenderers..::.LayoutRenderer
    NLog.LayoutRenderers..::.AspNetApplicationValueLayoutRenderer

See Also