Questions

Validate query parameters without using a model in .netcore api

Is it possible to validate query parameters on an action without using a model? A lot of the calls in my API are one-offs and I don't see a point in making models for them if they will only be used on...

24 Oct at 20:49

What is happening with this C# object initializer code?

What is going on with this C# code? I'm not even sure why it compiles. Specifically, what's going on where it's setting Class1Prop attempting to use the object initializer syntax? It seems like invali...

24 Oct at 20:4

Use a Inline Table-Valued Functions with Linq and Entity Framework Core

I created an Inline Table-Valued Functions (ITVF) in SQL Server that returns a table of values (query simplified for discussion purposes): ``` CREATE FUNCTION dbo.VehicleRepairStatus() RETURNS TABLE ...

Spring post method "Required request body is missing"

``` @PostMapping(path="/login") public ResponseEntity<User> loginUser(@RequestBody Map<String, String> userData) throws Exception { return ResponseEntity.ok(userService.login(userData)); } ``` I...

24 Oct at 18:14

How do you access appsetting.json parameters in an AuthorizeAttribute class in .Net Core

In my ASP.NET Core MVC app, I have a class that inherits from AuthorizeAttribute and implements IAuthorizationFilter. ``` namespace MyProject.Attributes { [AttributeUsage(AttributeTargets.Class |...

Entity Framework Core - Setting Value Converter generically

I'm currently trialing Entity Framework Core 2.1 with a view to using it in the company I work for's business applications. I've got most of the way in implementing Value Converters in my test project...

NSubstitute : Mocking REST API, return result based on parameter value

I am using NSubstitute to mock result of servicestack REST API which returns the employee object ``` var mockedCoreService = Substitute.For<jsonClient>(ApiUrl); //Create the employee to return for ...

16 Feb at 06:39

Ambiguous match found when using reflection to find Generic method

I'm using reflection to find the generic method for Newtonsoft `JsonConvert.DeserializedObject` but am finding that it's returning an ambiguous match for the non-generic version `JsonConvert.Deseriali...

How to prevent a JsConfig scope from affecting global settings

In `AppHost.Configure` I set a global JSON config `JsConfig.TreatEnumAsInteger = false;` and have a simple handler with two GET endpoints ``` public object Get(GetDayOfWeekAsText request) { retur...

23 Oct at 20:35

How to prevent RequestLogsFeature from skipping a request after a Gateway call is made during request handling

If a request handler uses the build-in `IServiceGateway` the request called by the gateway will be logged, not the original request. e.g. ``` public object Post(DoSomething request) { /* handle r...

23 Oct at 20:11

ASP.NET Core 2.1 no HTTP/HTTPS redirection in App Engine

# Problem I could not get the automatic redirection from HTTP to HTTPS to work correctly when the app is published to App Engine. When i access the website through the site got routed to [http:/...

grpc unhandled exception StatusCode=Unknown when invoking a method generated from a proto file

I have a client and server and get an unhandled exception of type `Grpc.Core.RpcException` with `Status(StatusCode=Unknown, Detail="Exception was thrown by handler.")` when invoking the `SendMessage`...

15 Jan at 14:23

Could not install packages due to an EnvironmentError: [Errno 13]

In my MacOS Mojave terminal I wanted to install a python package with pip. At the end it says: ``` You are using pip version 10.0.1, however version 18.1 is available. You should consider upgrading v...

6 Sep at 13:59

Bool value of Tensor with more than one value is ambiguous in Pytorch

I want to create a model in pytorch, but I can't compute the loss. It's always return Actually, I run example code, it work. ``` loss = CrossEntropyLoss() input = torch.randn(8, 5) input target = ...

11 Jun at 12:48

How to get HttpRequest body in .net core?

I want to get Http Request body in .net core , I used this code: ``` using (var reader = new StreamReader(req.Body, Encoding.UTF8)) { bodyStr = reader.ReadToEnd(); } req.Body.Position = 0 ```...

How to execute .Net Core 2.0 Console App using Windows Task Scheduler?

I have one Console App which is created using `asp.net Core 2.0` in `VS2017`. Now I want to run this application on particular time period repeatedly (like service). So I have tried this using `Window...

Why are 1000 threads faster than a few?

I have a simple program that searches linearly in an array of 2D points. I do 1000 searches into an array of 1 000 000 points. The curious thing is that if I spawn 1000 threads, the program works as...

25 Oct at 16:5

CSS `height: calc(100vh);` Vs `height: 100vh;`

I'm working on a project where the former developer used: ``` .main-sidebar { height: calc(100vh); } ``` I have no way to contact him/her anymore, and I would like to understand what is the dif...

23 Oct at 04:46

The SSL connection could not be established

I am using a third party library ([Splunk c# SDK](http://dev.splunk.com/csharp) ) in my ASP.NET core application. I am trying to connect to my localhost Splunk service via this SDK, but I get an exce...

Why CancellationToken is a struct?

Does it make any sense to use a struct instead of a reference type in case of CancellationToken? I see one possible disadvantage, it will be copied all the way down in methods chain as I pass it as a...

22 Oct at 20:50

ServiceStack IdentityServer4 - IdentityServerAuthFeature

I want to use IdentityServer with my ServiceStack API, however, when I add this in my Startup.cs in this method: ``` Plugins.Add(new IdentityServerAuthFeature { AuthProviderType = Iden...

23 Oct at 14:31

How to make partial method async

I have a generated code with partial method ``` { ... partial void InterceptOperationCall(IOperationContext context); ... async Task SomeMethod() { InterceptOperationCal...

25 Oct at 08:23

Unable to resolve ILogger from Microsoft.Extensions.Logging

I've configured my console application's `Main` like so ``` var services = new ServiceCollection() .AddLogging(logging => logging.AddConsole()) .BuildServiceProvider(); ``` And then I try to ...

IHttpClientFactory in .NET Core 2.1 Console App references System.Net.Http

- - I'm attempting to create a console app using the dotnet core framework. The console app needs to make API requests. I've read about the new `IHttpClientFactory` released as part of d...

21 Oct at 17:27

Quotes not around values in CSV

I'm using `ToCsv()` on a collection to convert it to CSV text. None of the values have quotes around them - even when there are spaces in them. How do I switch quotes on?

21 Oct at 17:26