asp.net-core-3.1

Create shorter tokens with small lifespan in ASP.NET Core Identity

寵の児 提交于 2021-02-08 07:19:27
问题 Using ASP.NET Core 3.1 I am creating an User's Email confirmation token to send by email: String token = await _userManager.GenerateEmailConfirmationTokenAsync(user); And I get the following: CfDJ8IjJLi0iO61KsS5NTyS4wJkSvCyzEDUBaVlXCkbxz6zwI1LocG8+WPubx5Rvoi4tFuiWAVFut4gfTnhgsdihE0gY+o7JyJrNtfXmzGLnczwbKZ3Wwy15+IUEi1h2qId72IRKvFqBSFv7rJdECSR/thZphpTQm7EnOuAA7loHlQFRWuMUVBce8HUsv1odbLNsKQ== How can I create shorter tokens with a small lifespan instead of huge tokens? 回答1: If I understand the

Why do I need to call twice the Set on my size limited MemoryCache when I hit the size limit?

风流意气都作罢 提交于 2021-02-07 19:10:49
问题 We are about to use the built-in in-memory cache solution of ASP.NET Core to cache aside external system responses. (We may shift from in-memory to IDistributedCache later.) We want to use the Mircosoft.Extensions.Caching.Memory's IMemoryCache as the MSDN suggests. We need to limit the size of the cache because by default it is unbounded. So, I have created the following POC application to play with it a bit before integrating it into our project. My custom MemoryCache in order to specify

Why do I need to call twice the Set on my size limited MemoryCache when I hit the size limit?

倖福魔咒の 提交于 2021-02-07 19:08:36
问题 We are about to use the built-in in-memory cache solution of ASP.NET Core to cache aside external system responses. (We may shift from in-memory to IDistributedCache later.) We want to use the Mircosoft.Extensions.Caching.Memory's IMemoryCache as the MSDN suggests. We need to limit the size of the cache because by default it is unbounded. So, I have created the following POC application to play with it a bit before integrating it into our project. My custom MemoryCache in order to specify

In .NET Core 3.1, the RequestCookieCollection can no longer be used to create cookies in unit tests

我只是一个虾纸丫 提交于 2021-02-07 12:14:25
问题 I have just upgraded from .NET Core 2.2 to 3.1. I have tests to confirm that extension methods I've added to HttpContext.Request are working. I was previously able to do things like: var context = new DefaultHttpContext(); var c = new Dictionary<string, string> {{"test", "passed"}}; context.Request.Cookies = new RequestCookieCollection(cookies); var result = context.Request.GetPrimedValue(); Is this impossible now? I tried using Moq for this, but there are far too many things blocking me from

In .NET Core 3.1, the RequestCookieCollection can no longer be used to create cookies in unit tests

自作多情 提交于 2021-02-07 12:12:13
问题 I have just upgraded from .NET Core 2.2 to 3.1. I have tests to confirm that extension methods I've added to HttpContext.Request are working. I was previously able to do things like: var context = new DefaultHttpContext(); var c = new Dictionary<string, string> {{"test", "passed"}}; context.Request.Cookies = new RequestCookieCollection(cookies); var result = context.Request.GetPrimedValue(); Is this impossible now? I tried using Moq for this, but there are far too many things blocking me from

trying to set config value `IHostBuilder` but not reflected for ConfigureServices in Startup class - asp.net core 3.1

好久不见. 提交于 2021-02-05 08:52:08
问题 I have below config with empty connection string, "ConnString": { "Value": "" }, Now in Asp.Net Core 3.1 app I am trying to set the connection string value inside CreateHostBuilder public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.ConfigureAppConfiguration((context, config) => { var settings = config.Build(); settings["ConnString:Value"] = "MY CONNECTION STRING"; }); webBuilder.UseStartup<Startup

Azure AD v2.0-specific optional claims missing from ID Token

我只是一个虾纸丫 提交于 2021-02-04 21:46:59
问题 I'm trying to add optional claims using Microsoft Identity Web - NuGet for user authentication in NET Core 3.1 WebApp. Reading the MS Docs, it seems that the only steps needed are to declare the optional claims within the App Registration Manifest file in Azure. But when testing the login process using two different apps (my own code and an MS project example) it looks like the optional claims are not being added to the ID Token when returned from Azure following a successful login i.e they

Azure AD v2.0-specific optional claims missing from ID Token

无人久伴 提交于 2021-02-04 21:46:38
问题 I'm trying to add optional claims using Microsoft Identity Web - NuGet for user authentication in NET Core 3.1 WebApp. Reading the MS Docs, it seems that the only steps needed are to declare the optional claims within the App Registration Manifest file in Azure. But when testing the login process using two different apps (my own code and an MS project example) it looks like the optional claims are not being added to the ID Token when returned from Azure following a successful login i.e they

Azure AD v2.0-specific optional claims missing from ID Token

眉间皱痕 提交于 2021-02-04 21:46:25
问题 I'm trying to add optional claims using Microsoft Identity Web - NuGet for user authentication in NET Core 3.1 WebApp. Reading the MS Docs, it seems that the only steps needed are to declare the optional claims within the App Registration Manifest file in Azure. But when testing the login process using two different apps (my own code and an MS project example) it looks like the optional claims are not being added to the ID Token when returned from Azure following a successful login i.e they

Asp.Net Core 3 graceful shutdown throws OperationCanceledException

ぃ、小莉子 提交于 2021-02-04 16:45:31
问题 I'm trying to gracefully terminate a ASP.Net Core 3.1 service (which will run in Kubernetes). When Kubernetes stops a service, it will send a SIGTERM event to the application, at which point I want in-flight requests to complete (which may take several seconds) before terminating... I think I can catch this in a hostedservice, as below, and hence not stop immediately. The following works, but with a timeout of 5 seconds or longer, I receive an OperationCanceledException. Could anyone shed any