Questions

How to do DI in asp.net core middleware?

I am trying to inject dependency into my middleware constructor as follows ``` public class CreateCompanyMiddleware { private readonly RequestDelegate _next; private readonly UserManager<Appl...

How do I prevent StyleCop warning of a Hungarian notation when prefix is valid

I have the following code: ``` var fxRate = new FxRate(); ``` which is giving me the following [StyleCop ReSharper](https://github.com/StyleCop/StyleCop.ReSharper) warning: > The variable name 'fx...

HttpClientFactory - Get a named, typed client by its name

HttpClientFactory offers the following extension method: ``` public static IHttpClientBuilder AddHttpClient<TClient>(this IServiceCollection services, string name) ``` and I've created a typed Http...

6 Sep at 10:47

Why Logging doesn't use string interpolation

I have been following [Logging in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1) Which is working just fine. I have a question about this line...

6 Sep at 09:15

Unexpected double WHERE clause in Servicestack OrmLite

We have an issue that occurs at every method call for limited periods of time. Then it works as expected. The issue is that the code produces double WHERE clauses. We're using Servicestack The meth...

6 Sep at 07:53

WSL Redis encountered System has not been booted with systemd as init system (PID 1). Can't operate

I'm trying to follow the Redis installation process that was discuss in this [article](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04) of digital o...

Changing the Base Address of a HttpClient

When writing an application that uses HttpClient I have the same approach as [this post](https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/), in other words and instead use a static HttpC...

6 Sep at 03:10

How can I fix git commit error "Waiting for your editor to close the file..." with VS Code?

I'm trying just `git commit` and Git is giving this message: > hint: Waiting for your editor to close the file... /c/Users/AGT/AppData/Local/Programs/Microsoft VS Code/bin/code: line 28: /Code.ex...

18 Sep at 04:37

The explicit binding redirect conflicts with an autogenerated binding redirect

I am receiving the following warning when I build my solution: > The explicit binding redirect on "Microsoft.Azure.Documents.Client, Culture=neutral, PublicKeyToken=31bf3856ad364e35" conflicts with a...

5 Sep at 23:46

Using cookies in ASP.NET Core 2.1

I have a simple ASP.NET Core 2.1 application which is supposed to set and then read a cookie. Whenever I try to read the cookie it returns null. Looking further in the browser's inspect tool I am una...

10 Jan at 00:9

'Migrations' does not exist in the namespace 'Microsoft.EntityFrameworkCore'

I'm doing a ASP.NET Core project. I've installed `Microsoft.EntityFrameworkCore` and `Microsoft.EntityFrameworkCore.Tools` NuGet packages. I ran `Add-Migration InitialCreate` command, Which created `...

5 Sep at 18:20

OrmLite doesn't apply soft delete filter on joins

I've added a `SqlExpressionSelectFilter` to use the [soft delete](https://github.com/ServiceStack/ServiceStack.OrmLite#soft-deletes) functionality in ServiceStack OrmLite. However, It only seems to ap...

5 Sep at 17:21

C# access unmanaged array using Memory<T> or ArraySegment<T>?

With the introduction of `Memory`, `Span` and `ArraySegment` in C# 7.2, I was wondering if I could represent an unmanaged array as an enumerable object, that lives on the heap. This latter requiremen...

5 Sep at 17:18

How to test if a user has a role within a service implementation in ServiceStack

I know I can add the RequiresAnyRole or RequiresRole attribute on my service: ``` [RequiresAnyRole("Admin", "HeadChaperone")] public GuestChaperoneResponse Delete(DeleteGuestChaperone request) ...

5 Sep at 16:7

How to get intellisense in Visual Studio Code for Unity functions names?

I am following a tutorial about Unity and I see that the instructor has intellisense when writes the method's name. However I have only intellisense with classes and variables, I mean Unity classes l...

Unable to resolve service for type 'System.Net.Http.HttpClient'

I created a `ViewComponent` class which call a `REST API` using the `HttpClient`, this is the code: ``` public class ProductsViewComponent : ViewComponent { private readonly HttpClient _client; ...

5 Sep at 14:50

In ASP.NET Core read JWT token from Cookie instead of Headers

I am porting an `ASP.NET Web API 4.6 OWIN` application to `ASP.NET Core 2.1`. The application is working based on `JWT` token. But the token in passed via cookie instead of header. I'm not sure why he...

How to set default value in material-UI select box in react?

I am using [Select box](https://material-ui.com/demos/selects/) from material-ui I want to show "select the value" option by default selected but after that user is not able to select this option. ...

Unable to consume WCF WSHttpBinding in .net core

I'am trying to move my project from .net to .net core. I was initially using WCF WSHttpBinding service in .net but I'am unable to consume the same in .net core. I tried using BasicHttpBinding to conne...

6 May at 20:37

How to extend DbContext with partial class and partial OnModelCreating method in EntityFramework Core

I'm using EF Core and DatabaseFirst approach. My dbContext is created automatically by `Scaffold-DbContext` command. I need to add some new DbSets into a dbContext and add into `OnModelCreating` metho...

Do I need to call SaveChanges when using EFCore.BulkExtensions

I started using EFCore.BulkExtensions for ef bulk operations, and it is working very nice. (see https://github.com/borisdj/EFCore.BulkExtensions/) do I need to call also to SaveChanges: or this is goo...

17 Jul at 08:28

High-performance TCP Socket programming in .NET C#

I know this topic is already asked sometimes, and I have read almost all threads and comments, but I'm still not finding the answer to my problem. I'm working on a high-performance network library tha...

11 Apr at 05:20

Fluent Validation chain rule not working with multiple When conditions

I got a really interesting behavior. I have the two test cases below: On my validator, if I have the following, the first test fails and the second passes. If I change the order of the rules, the firs...

6 May at 20:38

Funq: Register the same object multiple times and using an identifier (from session) to resolve them

I have a simple dictionary of type `string, DbContext` I am registering my Dictionary like this ``` container.Register<IDictionary<string, DbContext>>(x => dbContexts).ReusedWithin(ReuseScope.Reque...

4 Sep at 14:39

Identity Server 4 : Sorry, there was an error : unauthorized_client

I have set up identity server 4 to extent Umbraco so it uses a custom role provider. Everything was working but now when I get redirected to my Identity server I get this error: [](https://i.stack....

4 Sep at 16:59