How to use [FromHeader] attribute with custom model binding in Asp.Net Core 2.2
I need to add many custom headers in my request. I can use something like this ``` public ActionResult Get([FromHeader, Required]string header1, [FromHeader]string header2, ... , [FromHeader]string ...
- Modified
- 3 Sep at 13:30
Servicestack SendAll is working but sending an error
I am sending a CSV and de-serializing it. ``` List<CompanyService> responseX; using (var reader = new StreamReader(files[0].InputStream)) { // convert stream t...
- Modified
- 3 Sep at 21:46
React SPA / Embedded Identity Server issue after .net core 3 preview 8 upgrade
We have a React SPA which was initially created using the SPA templates and running on .NET Core 3 preview 7. The React SPA "The client" was configured for implicit flow and successfully using the oid...
- Modified
- 10 Oct at 14:47
Calling C# interface default method from implementing class
C# 8 supports default method implementations in interfaces. My idea was to inject a logging method into classes like this: ``` public interface ILoggable { void Log(string message) => DoSomething...
- Modified
- 9 Sep at 11:37
Conditional dependency resolver on run-time (.net Core)
I have two classes `PaymentGatewayFoo`, `PaymentGatewayBoo` that both implements a common interface of `IPaymentGateway`: ``` interface IPaymentGateway { } class PaymentGatewayFoo : IPaymentGateway ...
- Modified
- 2 Sep at 14:1
I have to integrate ServiceStack together with Kephas. How do I make them both play together with Dependency Injection?
ServiceStack uses a dialect of Funq (no support for metadata), where Kephas uses one of MEF/Autofac (requires metadata support). My question has two parts: - How to make ServiceStack and Kephas use o...
- Modified
- 2 Sep at 13:23
Postfix ! (exclamation) operator in C#
The last day I was exploring .NET sources on GitHub and stumbled upon the following construct: `((SomeTypeToCast)variable!).SomeMethodToCall()`. Please, notice the postfix which is oroginally liste...
- Modified
- 2 Sep at 11:5
"The project 'Web' must provide a value for Configuration" error after migrating to .NET Core 3
I've migrated an ASP.NET Core 2.2 project to Core 3.0 and am getting the error: > The project [Project location] must provide a value for Configuration. There's not really a lot to go on with that...
- Modified
- 3 Feb at 09:16
How to cancel .Net Core Web API request using Angular?
I have the following two applications - - I am making request to API using Angular's as shown below ``` this.subscription = this.httpClient.get('api/Controller/LongRunningProcess') ...
- Modified
- 1 Sep at 16:3
Unable to create an object of type 'MyContext'. For the different patterns supported at design time
I have ConsoleApplication on .NET Core and also I added my DbContext to dependencies, but howewer I have an error: > Unable to create an object of type 'MyContext'. For the different patterns supporte...
- Modified
- 7 Feb at 22:10
UserWarning: Could not import the lzma module. Your installed Python is incomplete
After Installing Google Cloud Bigquery Module, if I import the module into python code. I see this warning message. Happening to me in python 3.7.3 Virtualenv. Tried to reinstall GCP bigquery module ...
- Modified
- 13 Nov at 12:28
Blob Code download much slower than MS Azure Storage Explorer
I'm downloading a blob from blob storage that is 1GB in size. If I use MS Azure storage explorer it takes under 10 minutes (I have a 20 megabits down line). However when I use code: ``` await blobR...
- Modified
- 1 Jan at 10:6
How do I get the value of a tensor in PyTorch?
Printing a tensor `x` gives: ``` >>> x = torch.tensor([3]) >>> print(x) tensor([3]) ``` Indexing `x.data` gives: ``` >>> x.data[0] tensor(3) ``` How do I get just a regular non-tensor value `3`?
Response includes stacktrace even though DebugMode and WriteErrorsToResponse are disabled
I am running a self-hosted API on the latest version of ServiceStack (5.6.0). I am struggling to deal with exceptions early on in the request processing pipeline. More specifically when requests con...
- Modified
- 30 Aug at 12:5
How and Who calling the ConfigureServices and Configure method of startup class in .net core
As everyone know that Main method of Program.cs is the entry point of application. As you can see in the .net core default code created when we create any project. ``` public static void Main(string[]...
- Modified
- 18 Jan at 08:43
Curious ambiguity in attribute specification (two using directives)
In an [attribute specification](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/attributes#attribute-specification), there is sometimes two valid ways to wri...
- Modified
- 2 Sep at 13:37
TypeError: cannot unpack non-iterable int objec
How can I solve this error After running my code as follows . I am using the function below and implementin running window for loop on it but end up getting the error below. The for loop works and hun...
- Modified
- 13 Jan at 17:14
How to fix ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)?
I am trying to send an email with python, but it keeps saying `ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)`. Here is my code: ``` server = smtplib.SMTP_SSL('smtp.mail...
.NET Core environment variable returns null
I have a .NET Core console application. I'm trying to retrieve the environment variable using the below code. ``` var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); ``` ...
- Modified
- 28 Feb at 02:31
Mocking of extension method result in System.NotSupportedException
I'm unit testing a ClientService that uses the `IMemoryCache` interface: ClientService.cs: ``` public string Foo() { //... code _memoryCache.Set("MyKey", "SomeValue", new TimeSpan(0...
- Modified
- 29 Aug at 07:43
How do you read a simple value out of some json using System.Text.Json?
I have this json ``` {"id":"48e86841-f62c-42c9-ae20-b54ba8c35d6d"} ``` How do I get the `48e86841-f62c-42c9-ae20-b54ba8c35d6d` out of it? All examples I can find show to do something like ``` var ...
- Modified
- 27 Nov at 05:26
ServiceStack: AppHost.OnRequestEndCallbacks handler gets called twice when an exception is thrown outside of a service
I have a snippet in the OnEndRequestCallbacks block of the app host that records a row in an audit table for business purposes. The unexpected behavior is that when a request fails for some reason out...
- Modified
- 28 Aug at 19:6
VS 2019 optimize code in release mode broken?
For me it looks quite strange, and like a bug. This code in Release mode in Visual Studio 2019 provides infinite loop. ``` class Program { private static int _a; static void Main(string[] ar...
- Modified
- 28 Aug at 13:17
Detect if I clicked on a certain part of text
I'm using Unity to create an Android/IOS application. In a page containing a paragraph, I want to know if I click on the last sentence of the text. ("Click here for more details" for example). After ...
How could I avoid == null checking?
Here is my code which is used widely in project, and I'm wondering can I refactor this somehow so I might avoid `== null` checks all the time?