ASP.NET Request Form key/value pairs.
Platforms Supported: All
Introduced in NLog.Web 4.7
${aspnet-request-form:items=String[]:exclude=String[]:outputFormat=Enum :itemSeparator=Layout:valueSeparator=Layout :valuesOnly=Boolean}
Key1,Key2
Introduced with NLog.Web / NLog.Web.AspNetCore v5.2.2, and replaces the include-option.
include
Flat
JsonArray
Json
JsonDictionary
singleAsArray
,
=
false
Introduced in NLog.Web / NLog.Web.AspNetCore 5.1.1
Use this layout renderer to log the ASP.NET Request Form collection.
In C# code:
httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues>{ { "id","1" }, { "name","Test Person" }, { "token","86abe8fe-2237-4f87-81af-0a4e522b4140" } });
${aspnet-request-form}
Will print:
"id=1,name=Test Person,token=86abe8fe-2237-4f87-81af-0a4e522b4140"
${aspnet-request-form:OutputFormat=JSON}
[{"id":"1"},{"name":"Test Person"},{"token":"86abe8fe-2237-4f87-81af-0a4e522b4140"}]
${aspnet-request-form:items=id,name}
"id=1,name=Test Person"
${aspnet-request-form:Exclude=token}
${aspnet-request-form:ItemSeparator=${newline}}
"id=1\r\nname=Test Person\r\ntoken=86abe8fe-2237-4f87-81af-0a4e522b4140"
There was an error while loading. Please reload this page.