C#

C

C#

We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.

Join

Getting CORS issues when ASP.NET + frontend project is deployed to Azure

Access to fetch at '[backendURL]/Taxon/GetAll' (redirected from '[frontendURL]/api/Taxon/GetAll') from origin '[frontendURL]' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to fetch at '[backendURL]/Taxon/GetAll' (redirected from '[frontendURL]/api/Taxon/GetAll') from origin '[frontendURL]' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I've tried to configure ASP.NET to include the frontend URL as a specific CORS policy, as well as configuring the CORS to "AllowAll", yet I still get this issue....

New to C#, wanting to make a desktop application for windows 11 any recommendations?

Just started learning C#, and I am wanting to make a desktop app for windows 11, the application i want to make needs to handle data fetched from a server, sort it and display it (with graphs if possible). What are any recommendations with tools or frameworks for doing such things? I would prefer if its beginner friendly but as long as it can make what I want doesnt matter if it have big learning curve.

I am learning C#. I want to learn .net CORE. Any courses or where I could learn it?

I am learning C#. I want to learn .net CORE. Any courses or where I could learn it?

SequenceEqual with IEnumerable and Span?

Is there an extension that checks if an IEnumerable and a Span are SequenceEqual? Is there a similar thing in MSTest?

T4 templates in Entity Framework

Why does EF still has .tt files? How relevant are them, are them to generate code when creating a new project? Would EF work without them? https://github.com/search?q=repo%3Adotnet%2Fefcore+.tt&type=code&p=1...

Stackalloc a span of tuples?

Is it possible to stackalloc a span of tuples like this? Span<(object, string)> foos = stackalloc (object, string)[12];...
No description

Doing a print preview makes my form disappear

Hi! I have a label designer form and when I hit the preview button, my form disappears and another form in my application is visible. It's like the label designer form gets minimized. It's driving me nuts, lol Problem shown: https://www.youtube.com/watch?v=4dH4FRoBDHg...

āœ… Works in live server, breaks in minimal server. I am a fool.

I'm doing something big-time stupid trying to serve this webpage It works fine with the VSCode extension live server preview, but when I run my custom server, despite (as far as I can tell) serving all the files correctly with the correct mime types, I get a reference error immediately, with the inline JS unable to reference the odin variable defined in odin.js ``` Uncaught ReferenceError: odin is not defined at index.html:33:29...

Best ASP.NET MVC project structure for a minimal viable product?

I'm creating a minimal viable product in ASP.NET MVC. I read this section on the Microsoft website (https://learn.microsoft.com/en-us/dotnet/architecture/modern-web-apps-azure/common-web-application-architectures?utm_source) and I'm considering using a similar structure. However, would this be recommended? Is there another structure that is more generally used? I don't want it to be too advanced but it needs to have good separation of concerns.

OpenAPI generator for C#, having issues with an endpoint that returns two types

Hi everyone, I'm working on a fork of a generated library and attempting to bring my own changes to it, by creating a wrapper for .NET DI and and cleaning up how the API is used. If you look at https://github.com/vrchatapi/vrchatapi-csharp/ you can see the generated API is quite a bit messy and the maintainers don't have much experience with C#....

how to open interactive window in visual studio 2026 auto with code?

how to open interactive window in visual studio 2026 auto with code? i tried hard with allot of methods ```cs...
No description

Do I need a dedicated User entity to manage Auth0 users in my database, or is storing the Auth0 ID s

Should I create a separate User entity in my database to sync with Auth0, or should I just store the Auth0 ID (sub) as a string reference in my domain entities like Todo? The reason I'm asking is because I want to implement an email service in the backend, and I need to know the best way to manage user data for sending emails.

Plugins in .NET

Using the newest version of .NET, how well can a plugin system be implemented where plugins a) are loaded at runtime b) are unloaded at runtime c) can depend on each other d) can optionally depend on each other...

Setting up test relations

I want to create some dummy data for my database for integration testing. Im not sure how to do relations right. This is my user entity. I create some dummy users and dogs with bogus but how do i actually link them? ```public sealed class User : IdentityUser<int> { public string? Bio { get; set; } = string.Empty;...

āœ… WSL dotnet CLI problem

Hi guys! I don't know what I've done, but for some reason when I try to run dotnet run on a minimal api project it just builds and doesn't show any errors or warnings, but it also doesn't run on the provided port and this happens in the PowerShell and in the WSL and I'm trying to setup a good development environment on the WSL to separate my dev work in the WSL and my personal stuff in Windows. Also in Docker when the container starts it shuts down right after without a warning or anything. An...
No description

Save project files on a hdd or ssd, does it matter?

Currently I am saving all my projects on my hdd. So I just wondered if it matters where I save my project files?

Fields marked as 'static'

Hey! I'm going through a Udemy course on C# and something has stumped me and I can't work it out... The video is covering fields within classes, which I understand fine. However, in the video, they have a 'int myResult' variable which isn't marked as static. The variable is being used in various methods without the compiler complaining. However, when I've recreated it, my variable needs to be marked as static. Here's my code...

SSL connection could not be established to login.microsoftonline.com

Hey! One of our three developers are receiving this error when trying to authenticate and fetch user tokens through Azure: ```...

[Authorize] Always Returns 401 Even With Valid-Looking JWT Token

I’m getting a 401 Unauthorized whenever I call my [Authorize] endpoint, even though I’m sending a JWT. The token appears correct on the client side — JWT decoders show the expected claims (screenshot 1), and the signature verifies. The token is stored in Local Storage (screenshot 2), and the frontend sends the header:
Authorization: Bearer eyJhbGciOiJIUzI1...
Authorization: Bearer eyJhbGciOiJIUzI1...
. However, the only endpoint protected with [Authorize] always returns 401 Unauthorized. C# backend exception:
IDX14102: Unable to decode the header 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' as Base64Url encoded string.
IDX14102: Unable to decode the header 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' as Base64Url encoded string.
. ...
No description
Next