-
Notifications
You must be signed in to change notification settings - Fork 165
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
aspnet-sessionId not working for Asp.Net Core (.Net 4.7) #153
Comments
we're using: var service = GetService<IHttpContextAccessor>()
var sessionid = service.HttpContext.Session.SessionID: does that one show the correct value in your program? |
Closing this due to inactivity. Please let us know if this still an issue and please provide the requested info. |
where using var service = GetService() |
This is still an issue. A reply to the OP would be nice :) |
When using this line in your code does that one show the correct value in your program? |
Where are you supposed to be able to call that method? Context is not set as an instance of a object. |
do you use
AFAIK |
Does the If so: For reference, this is in .NET Core. |
Which .net core version? This was build for .net core 1 |
.NET Core using ASP.NET framework 4.7 |
.net core 1? |
Yes |
You need https://www.nuget.org/packages/Microsoft.AspNetCore.Session/ for that |
This produces a session ID. However, |
You're missing `
? |
I assume your question has been answered, if not, let us know! |
Hi @304NotModified ! I use the wrapper class to log the data in the database, obviously for some of the layers aspnet-sessionid will not be available, is there a workaround to check context in layout if it is null to display empty value/or friendly message for logs, else display session Id.
I really appreciate help as want o get rid of the Object reference is not set as an instance of a object exception in internal nlog logs. The common wrapper class will throw the exception when you have a Data Access Layer and you call logger in it as it doesn't have a clue about HttpContext. |
Please open a new issue and fill in the template, thanks! |
We are trying to use aspnet-sessionid in an ASP.Net core application (.net version 4.7) and nLog is not showing it in the logs at all.
We tried with multiple different configuration values, but none produce any output.
Is this supposed to be working in ASP.Net Core and .Net 4.7?
For reference:
In Startup.cs
nLog.config file
The text was updated successfully, but these errors were encountered: