Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNX / ASP 5 - ${aspnet-request:serverVariable result in System.NotSupportedException #39

Closed
sgutkin opened this issue Mar 15, 2016 · 3 comments
Labels
Milestone

Comments

@sgutkin
Copy link

sgutkin commented Mar 15, 2016

The documentation https://github.com/NLog/NLog/wiki/AspNetRequest-layout-renderer

implies that serverVariable works for asp.net5 /coreclr but the source code

https://github.com/NLog/NLog.Web/blob/master/NLog.Web.ASPNET5/LayoutRenderers/AspNetRequestValueLayoutRenderer.cs

explicitly seems to throw an exception :

else if (this.ServerVariable != null)
{
#if !DNX
builder.Append(httpRequest.ServerVariables[this.ServerVariable]);
#else
throw new NotSupportedException();
#endi

For example in my nlog.config, the first 3 parameters work fine but the last two throw internal nlog exceptions (Warn Exception in layout renderer. Exception: System.NotSupportedException: Specified method is not supported.)

  • parameter name="@requestmethod" layout="${aspnet-item:variable=RequestMethod}"/
  • parameter name="@responseParamThree" layout="${aspnet-request:header=X-Forwarded-For}"/
  • parameter name="@responseParamFour" layout="${aspnet-request:serverVariable=REMOTE_ADDR}"/
  • parameter name="@responseParamFive" layout="${aspnet-request:serverVariable=ALL_RAW}"/

From project.json

"dependencies": {
.....
"NLog": "4.4.0-beta1",
"NLog.Config": "4.3.0-beta1",
"NLog.Extensions.Logging": "1.0.0-rc1-final-2016-03-11",
"NLog.Schema": "4.3.0-beta1",
"NLog.Web.ASPNET5": "4.2.1",
.......

@304NotModified
Copy link
Member

That's sloppy documentation. We can't read the server variables in dnx (or AFAIK)

@sgutkin
Copy link
Author

sgutkin commented Mar 15, 2016

Yeah I figured as much. In RC1 the remote IP isn't readily accessible on Microsoft.AspNet.Http.HttpContext. I think they plan to fix it for RC2.

@304NotModified
Copy link
Member

superseded by #44

304NotModified added a commit that referenced this issue May 24, 2016
Remove nonsupported property from API

Fixes #40, fixes #39
304NotModified added a commit that referenced this issue May 24, 2016
Remove nonsupported property from API

Fixes #40, fixes #39
kvpro929 added a commit to kvpro929/NLog.Web that referenced this issue Oct 30, 2022
@snakefoot snakefoot added bug and removed known issue labels Jan 10, 2023
@snakefoot snakefoot added this to the 4.3 milestone Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants