.net-core

Problem in Lazy Connection logic in stackexchenage.redis

杀马特。学长 韩版系。学妹 提交于 2021-01-07 01:36:17
问题 I am facing one problem that for instance my redis server was unavaialble at start but starts later. But due to above logic my Muxer object always remain un connected even though my redis is started. seems like there is no such thing as reconnect on failure or some thing. I am using following for Redis Connection in my .net core 3.1 application private static readonly Lazy Conn = new Lazy( () => { try { if (ConfigOptions != null && ConfigOptions.Value != null) { return ConnectionMultiplexer

Problem in Lazy Connection logic in stackexchenage.redis

流过昼夜 提交于 2021-01-07 01:35:32
问题 I am facing one problem that for instance my redis server was unavaialble at start but starts later. But due to above logic my Muxer object always remain un connected even though my redis is started. seems like there is no such thing as reconnect on failure or some thing. I am using following for Redis Connection in my .net core 3.1 application private static readonly Lazy Conn = new Lazy( () => { try { if (ConfigOptions != null && ConfigOptions.Value != null) { return ConnectionMultiplexer

How to create a ContextMenu with items generated from Binding and directly

一世执手 提交于 2021-01-07 01:07:59
问题 Thanks to great @thatguy help I was able to create the menu dynamically, all details and explanation here: How to avoid repeating blocks of XAML in a menu It works perfectly but my problem is that at the end of the list I need to add a separator and a Delete item. This was the code I was using: <ContextMenu ItemsSource="{Binding MyTypes}" ItemContainerStyle="{StaticResource MyMenuItemStyle}"> <Separator HorizontalAlignment="Stretch" Visibility="{Binding MenuSelected.Type, Converter=

How to create a ContextMenu with items generated from Binding and directly

核能气质少年 提交于 2021-01-07 01:07:07
问题 Thanks to great @thatguy help I was able to create the menu dynamically, all details and explanation here: How to avoid repeating blocks of XAML in a menu It works perfectly but my problem is that at the end of the list I need to add a separator and a Delete item. This was the code I was using: <ContextMenu ItemsSource="{Binding MyTypes}" ItemContainerStyle="{StaticResource MyMenuItemStyle}"> <Separator HorizontalAlignment="Stretch" Visibility="{Binding MenuSelected.Type, Converter=

Using RunImpersonated for an HttpClient call fails for a NUnit test, but works in Console

让人想犯罪 __ 提交于 2021-01-05 08:53:45
问题 I need to have my tests run as a testing account. To accomplish that I setup to the following code to create a handle into my testing account: SafeAccessTokenHandle testAccountHandle; bool returnValue = LogonUser("TestAccount", "myDom.net", "pass", 2, 0, out testAccountHandle); I can then make a call to load a URL: HttpResponseMessage response = null; await WindowsIdentity.RunImpersonated<Task>(testAccountHandle, async () => { var url = "https://accounts.google.com/.well-known/openid

Migrating from ASP.NET Core 2.2 to 3.1

99封情书 提交于 2021-01-05 07:16:07
问题 We currently have an ASP.NET Core 2.2 web app that we would like to migrate to 3.1 (as it's newer and contains several enhancements). There are articles on migrating from 2.2 to 3.0 but not 2.2 to 3.1 . Is the preferred migration route to upgrade to 3.0 first then upgrade to 3.1? There seem to be a lot of incompatibilities between 2.2 and the newer 3.0 / 3.1 frameworks. Are there any best practices / general guidelines for upgrading an existing ASP.NET Core 2.2 web app to 3.0 / 3.1 ? 回答1:

ASP.NET Core 3.1.1 Jwt redirects instead of returning http status 401 after migration from ASP.NET Core 2.2

混江龙づ霸主 提交于 2021-01-04 14:54:59
问题 After migrating my website from .NET Core 2.2 to 3.1.1, my api endpoints suddenly started trying to redirect my api request to a default login page ( /Account/Login?ReturnUrl= , which I don't even have in any of my routes). My api is using a JWT bearer authentication scheme, with JWT Challenge Scheme, but still the redirect happened. services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults

Catching Exceptions in async methods when not called with await

女生的网名这么多〃 提交于 2021-01-03 05:35:40
问题 Goal: I am confused by the behavior I am seeing with exceptions in my .Net Core library. The goal of this question is to understand why it is doing what I am seeing. Executive Summary I thought that when an async method is called, the code in it is executed synchronously until it hits the first await. If that is the case, then, if an exception is thrown during that "synchronous code", why is it not propagated up to the calling method? (As a normal synchronous method would do.) Example Code:

Catching Exceptions in async methods when not called with await

冷暖自知 提交于 2021-01-03 05:34:34
问题 Goal: I am confused by the behavior I am seeing with exceptions in my .Net Core library. The goal of this question is to understand why it is doing what I am seeing. Executive Summary I thought that when an async method is called, the code in it is executed synchronously until it hits the first await. If that is the case, then, if an exception is thrown during that "synchronous code", why is it not propagated up to the calling method? (As a normal synchronous method would do.) Example Code:

Correct pattern to dispose of cancellation token source

拈花ヽ惹草 提交于 2021-01-02 12:14:39
问题 Consider a scenario where you have some asynchronous work to be done and you can run it in a fire and forget mode. This asynchronous work is able to listen for cancellation and so you pass it a cancellation token in order to being able to cancel it. At a given moment in time we can decide to request the cancellation of the ongoing activity, by using the cancellation token source object from which we have taken the cancellation token. Because cancellation token source implements IDisposable ,