ASP.NET Core CORS WebAPI: no Access-Control-Allow-Origin header
I have deployed my ASP.NET Core web API to Azure, and I can access its endpoints using Swagger or a web debugger like Fiddler. In both cases (same origin in Swagger, different origin using Fiddler fro...
- Modified
- 23 May at 10:31
Entity framework automatically renaming many-to-many tables without any changes
I've been working in the same project for almost 1½ year and today when I wanted to add a change to the db (code first). All of the sudden EF migration wants to rename a lot of the many-to-many tables...
- Modified
- 6 May at 07:23
Why is infinity printed as "8" in the Windows 10 console?
I was testing what was returned from division including zeroes i.e. `0/1`, `1/0` and `0/0`. For this I used something similar to the following: ``` Console.WriteLine(1d / 0d); ``` However this code...
C# 7.0 "deconstructor"
I'm reading about [C# 7.0 new stuff](https://msdn.microsoft.com/magazine/mt790184?MC=Vstudio&MC=.NET&MC=MSAzure&MC=CSHARP&MC=DevOps), and I cannot grok, at least from the example given, what would be ...
Where's the NuGet package location in ASP.NET Core?
I'm new to ASP.NET Core, and am trying to figure out where NuGet packages are stored on my local machine. I've installed the following NuGet packages: ``` nuget dapper nuget MicroOrm.Pocos.SqlGener...
- Modified
- 22 Apr at 23:12
ServiceStack Route using array as parameters
I need to create this `URL` for request using `ServiceStack`, but I couldn't find a way to generate this as `URL` route: [http://server.com/myserver?service=2&item[0].reference=222&item[1].reference=...
- Modified
- 1 Dec at 02:54
Dependency Injection error: Unable to resolve service for type while attempting to activate, while class is registered
I created an .NET Core MVC application and use Dependency Injection and Repository Pattern to inject a repository to my controller. However, I am getting an error: > InvalidOperationException: Unable ...
- Modified
- 15 Sep at 08:41
Does C# 7 allow to deconstruct tuples in linq expressions
I'm trying to deconstruct a tuple inside a Linq expression ``` // somewhere inside another method var result = from word in words let (original, translation) = Convert(word) ...
DateTime.Now retrieval speed
Is there any chance that this statement would return true DateTime.Now == DateTime.Now can a very fast machine return true for this statement, I tried on several machines and its always false ?
ASP.NET add migration 'composite primary key error' how to use fluent API
Hello I am in the process of creating a Web Application and have already installed both the and . During the process of executing an add-migration in the package manager console I get an error "" ...
- Modified
- 30 Nov at 21:36
Object reference not set to an instance of an object when trying to log service exceptions servicestack
I'm getting the following message: > Object reference not set to an instance of an object When trying to log the exceptions thrown by the service, I'm using the following service exception handler i...
- Modified
- 30 Nov at 19:48
'List' does not contain a definition for 'Where'
I am trying to create a method where I can pass a `Linq` expression as a parameter to return a new list of items. Currently I am doing this ([based off this answer](https://stackoverflow.com/question...
Support SQL Server change tracking with Entity Framework 6
I have an Entity Framework 6 Code First model generated from an existing SQL Server database. The database is using SQL Server Change Tracking, so for all the data manipulation operations generating f...
- Modified
- 5 Dec at 10:28
Multiple controllers with same URL routes but different HTTP methods
I've got a following two controllers: ``` [RoutePrefix("/some-resources") class CreationController : ApiController { [HttpPost, Route] public ... CreateResource(CreateData input) { ...
- Modified
- 5 Dec at 15:5
.NET Core and System.Drawing
I am trying to reference System.Drawing in a .net core console app targeting net46 but the assembly is not there. According to MS if you use dotnetcore System.Drawing is not available. But if you refe...
- Modified
- 20 Oct at 15:19
Xamarin.Forms.Color to hex value
I have a Xamarin.Forms.Color and I want to convert it to a 'hex value'. So far, I haven't found a solution to my problem. My code is as follows: ``` foreach (var cell in Grid.Children) { var pixel...
- Modified
- 18 Aug at 18:56
Windows Defender Antivirus scan from C# [AccessViolation exception]
We are writing a code to do on-demand scan of a file from C# using Windows Defender APIs. ``` [DllImport(@"C:\Program Files\Windows Defender\MpClient.dll")] public static extern int WDStatus(...
- Modified
- 28 Dec at 12:10
Using an array as argument for string.Format()
When trying to use an array as an argument for the `string.Format()` method, I get the following error: > FormatException: Index (zero based) must be greater than or equal to zero and less than the s...
- Modified
- 30 Nov at 11:0
ServiceStack.Redis deserialization issue - sometimes JSON is corrupted
I got a service that uses ServiceStack.Redis for storing objects (serialized with JSON). There's a key that's updated with each HTTP request - the flow is simple: get value for the key, deserialize it...
- Modified
- 30 Nov at 10:12
Configuring Serilog RollingFile with appsettings.json
I'm trying to configure Serilog for a .NET Core project. Here's what I have in my `appsettings.json`: ``` "Serilog": { "MinimumLevel": "Verbose", "Enrich": ["FromLogContext", "WithMachineName...
.NET Core Unit Testing - Mock IOptions<T>
I feel like I'm missing something really obvious here. I have classes that require injecting of options using the .NET Core `IOptions` pattern(?). When I unit test that class, I want to mock various v...
- Modified
- 4 Nov at 00:30
ServiceStack DateTime Deserialize Issue
It looks like ServiceStack doesn't like me using a DateTime property as an argument in my request. I'm getting a "Bad Request" message... no other helpful detail in the exception. The inner exception ...
- Modified
- 30 Nov at 18:53
How to change object's layer at runtime in Unity?
I've got WallCreator script to place walls in Unity, and another one, WallCreatorSwitcher to turn WallCreator ON/OFF by checking the toggle. I also wanted to change wallPrefab's layer there by using `...
Routes in ASP.net Core API
I read lot of topic about routes for API in Asp.net core but I cannot make it work. First, this is my controller : ``` Public class BXLogsController : Controller { //[HttpGet("api/[controller]/I...
- Modified
- 17 Jul at 16:2