Questions

How to mock the new HttpClientFactory in .NET Core 2.1 using Moq

.NET Core 2.1 comes with this new factory called `HttpClientFactory`, but I can't figure out how to mock it to unit test some methods that include REST service calls. The factory is being injected us...

How to use bearer authentication in openapi-codegen generated python code

I am using the OpenApi 3.0 specification to document my API. It is basically a REST API which requires a valid Bearer token for each request except for the login request. The OpenAPI spec looks like t...

Mocking EF core dbcontext and dbset

I am using ASP.NET Core 2.2, EF Core and MOQ. When I run the test I am getting this error: > Message: System.NotSupportedException : Invalid setup on a non-virtual (overridable in VB) member: x => x....

The non-generic method 'IServiceProvider.GetService(Type)' cannot be used with type arguments

I am using .NET Core dependency injection, but when I am trying to get the service in another class, I am getting the 'IServiceProvider.GetService(Type)' cannot be used with type arguments' error. W...

AspNet Core Logging working but not inside ServiceStack services when hosted in Azure

I have a simple ServiceStack service with some logging added. ``` log.Info("In Vehicle service request"); if (log.IsDebugEnabled) log.Debug("Debugging Vehicle service request"); ``` log is defi...

How to start HostedService in MVC Core app without http request

In my MVC .NET core 2.2 app there is HostedService which doing background work. It is register in ConfigureServices method of Startap class ``` services.AddHostedService<Engines.KontolerTimer>(); ``...

how to fix 'Access to XMLHttpRequest has been blocked by CORS policy' Redirect is not allowed for a preflight request only one route

[](https://i.stack.imgur.com/8BpwB.png)[](https://i.stack.imgur.com/FAz9Q.png)i'm setting a laravel and vuejs. CORS plugin for laravel and frontend side i use Axios to call REST api i got this ERROR...

17 Jan at 05:30

convert object to CSV string without header Servicestack CSVSerializer

I'm using Servicestack.text CSV serializer to serialize an object into CSV format. Here is the way Im trying ``` CsvSerializer.SerializeToString(MyObject) ``` But it converts into CSV including the...

16 Jan at 06:9

File upload to wwwroot folder in ASP.NET Core

Why is my following codes sometimes work, but sometimes it does't work? ``` private bool UploadFile(IFormFile ufile, string fname) { if (ufile.Length > 0) { string fullpath = Pat...

16 Jan at 06:0

The correct way to pass the connectionstring from Startup to any other controller

I am currently creating a Angular application with servicestack and asp.net core 2.1. I have problem with passing the connectionstring from "Startup" to the "AppHost.Configure" function (AppHost inher...

15 Jan at 22:23

Enum as Required Field in ASP.NET Core WebAPI

Is it possible to return the `[Required]` attribute error message when a JSON request doesn't provide a proper value for an enum property? For example, I have a model for a POST message that contains...

26 Jul at 20:28

Entity Framework Core - Multiple one-to-many relationships between two entities

I have two entities - and . A team can have many games (One-To-Many). So that would look something like this: ``` public class Team { public int Id { get; set; } public string N...

15 Jan at 10:1

What is SetCompatibilityVersion inside of the startup class of asp.net Web API core project

Using Visual Studio 2017, I just created a simple API project as shown below. And in the Startup.cs file I have this code. ``` public void ConfigureServices(IServiceCollection services) { servi...

15 Jan at 06:41

Surprisingly different performance of simple C# program

Below is a simple program that with a small change, makes a significant performance impact and I don't understand why. What the program does is not really relevant, but it calculates PI in a very con...

19 Jan at 11:51

EF Core Connection to Azure SQL with Managed Identity

I am using EF Core to connect to a Azure SQL Database deployed to Azure App Services. I am using an access token (obtained via the Managed Identities) to connect to Azure SQL database. Here is how I ...

.Net Core unable to use Bitmap

I am working on a Web Service using .Net Core 2.1. I have a byte array containing all pixels values (in grey scale), a width, a height. I want to create a bitmap from theses parameters. There is my ...

14 Jan at 11:8

JS file gets a net::ERR_ABORTED 404 (Not Found)

I am trying to create a simple Io-web-chat. I recently wanted to seperate my `<script>` inside my html file to an external js file. ``` Chat |-- index.html |-- index.js `-- server.js ``` ``` <...

13 Jan at 21:41

Xamarin.Forms: bind to a code behind property in XAML

In Xamarin.Forms I would like to bind a code behind property to a label in XAML. I found many answers and web pages about this topic, but they all cover more complex scenarios. This is my XAML page:...

14 Jan at 07:36

Module not found: Error: Can't resolve 'crypto'

I am getting the following list of errors when I run `ng serve`. My package JSON is as follows: ``` { "name": "ProName", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve...

12 Jan at 17:47

Entity Framework Core migrations error using UseInMemoryDatabase

I'm trying to separate my Entity Framework and Identity to a different library but I can't do any migrations when I use `builder.UseInMemoryDatabase(connectionString);`. I can do migrations when I ch...

12 Jan at 07:7

Why is service stack returning a Int64 instead of Int32?

My model SecPermission has the column Id = int which is Int32. When I add a new record why is it returning the newly added ID as Int64? Service method ``` public object Post(AddPermission request) ...

11 Jan at 22:28

How to create custom actions in c# and bind it on a wix setup project

How do I create custom actions and link it to my WiX setup project? I have: - WiX 3.11 - Visual Studio

3 May at 05:10

Flutter: Outline input border

I was trying to build a border for my text field like: ``` return TextField( ... border: OutlineInputBorder( borderSide: BorderSide( color: Colors.red, width: 5.0), ) ) ) ``` But...

11 Jan at 09:21

Warning NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.1.6`

I have the following warning ``` Severity Code Description Project File Line Suppression State Warning NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of ...

11 Jan at 01:56

Cannot find name 'describe'. Do you need to install type definitions for a test runner?

When using TypeScript in conjunction with Jest, my specs would fail with error messages like: ``` test/unit/some.spec.ts:1:1 - error TS2582: Cannot find name 'describe'. Do you need to install type de...

23 Oct at 19:23