Questions tagged [ambientcontext]
6 questions
11
votes
3 answers
Creating an "Ambient Context" (UserContext) for an ASP.NET application using a static factory Func
I have found out that I need the current logged in user data in nearly every class (controllers, view, HTML helpers, services and so on). So I thought about to create an "Ambient Context" instead of injecting an IUserService or the User directly.…

Rookian
- 19,841
- 28
- 110
- 180
5
votes
1 answer
Access IServiceProvider when using generic IHostBuilder
I'm using IHostBuilder in a .NET Core 2.1 console application. Main looks like this:
public static async Task Main(string[] args)
{
var hostBuilder = new HostBuilder()
.UseServiceProviderFactory(new…

Timo
- 7,992
- 4
- 49
- 67
3
votes
0 answers
Ambient Context Where Members Have Dependencies
Hi this is probably just a lack of thought but I can't see how to solve this one "nicely". I have a component responsible for auditing that is used across the system, such:
public class RemoteAuditLogger: AuditLogger{}
where AuditLogger is an…

Dan Kendall
- 702
- 5
- 22
1
vote
0 answers
AsyncLocal & CallContext - How can I achieve both async *and* remoting logical context guarantees?
I'm attempting to develop a library that implements the loosely-defined Ambient Context pattern. I need to consider both a high-degree of parallelism and remoting (.NET Framework 4.6.2). It seems I have 2 options available: AsyncLocal and…

Matt
- 1,674
- 2
- 16
- 34
1
vote
1 answer
Which WCF's extension point should be used for setting context for each operation?
I want to setup ambient context (similar to how Thread.CurrentPrincipal works) for every operation of all services running inside the host.
What extension mechanism should I use? There are plenty of them so I'm confused since I have almost no…

Pavel Voronin
- 13,503
- 7
- 71
- 137
0
votes
1 answer
What dependency injection pattern to use for a MessageProvider?
I have a ContactController where I set up a message in the TempData (this is to display a message in the screen after successful submission) and in the layout, there's a partial _Message.cshtml that is supposed to render the message, if any. Method…

Fabio Milheiro
- 8,100
- 17
- 57
- 96