C#

C

C#

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

Join

docker

Error response from daemon: Mounts denied: The path /ASP.NET/Https is not shared from the host and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing. See https://docs.docker.com/desktop/mac for more info. docker-compose process finished with exit code 1...

Openapi to have XML documentation of the properties and endpoints.

anyone used openapi document? to get the xml documentation included in the openapi/v1.json ? I was using MartinCostello.OpenApi library. Please suggest to fix that. when i used below logic, it is giving me 500 internal server error. services.AddOpenApiExtensions(options => { options.AddServerUrls = true; options.XmlDocumentationAssemblies.Add(Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly());...

✅ Disposable class level property

Hello If there is a singleton service that uses a disposable class level property, should the service implement IDisposable as well? Also, wouldn't the property be disposed automatically upon application shutdown, only if it implements IDisposable? ...

FolderBrowserDialog on .net core

Hello, is there a native alternative to FolderBrowserDialog in .net core 9 that is compatible with all platforms?

Selenium - change trigerring

Hey, I'm adding new tests in Selenium and I have an issue probably with change triggering. I have a form with a few fields. First input field is "Code" field that I'm putting some code from scanner or manually and after that it triggers change event that parse code to 4 anotyher fields and disable them. It works if i'm doing it manually, it works if I run my test in debug step by step but if I just run tests from Visual Studio (without debugging) it parses value but the fields are not disables and this cause another errors but gues it's not important. I tried to add Thread.Sleep or some kind of wait after the code is entered but that does not help. Code is entered like this
Globals.CurrentWebDriver.FindVisibleElement(By.Id("ScannerReceipt")).SendKeys(fmdCode);
Globals.CurrentWebDriver.FindVisibleElement(By.Id("ScannerReceipt")).SendKeys(Keys.Enter);
Globals.CurrentWebDriver.FindVisibleElement(By.Id("ScannerReceipt")).SendKeys(fmdCode);
Globals.CurrentWebDriver.FindVisibleElement(By.Id("ScannerReceipt")).SendKeys(Keys.Enter);
Any idea what's wrong ? Thank you...

Which .NET UI platform to use?

I want to create a desktop app, but I'm unsure on whether I should use .NET MAUI, WinForms, WPF, WinUI, Avalonia or Uno?

Recommended flow for writing + deploying a basic Microservice Application (with DB)?

As per title, I am working on a basic API reliant service that will occasionally be called to store image metadata. I already have a Cloud Object Storage (COS), so I pretty much need a simple 2NF service to CRUD metadata locations for in-app image uploads. I have looked up a few resources: https://www.sentinelstand.com/article/guide-to-firebase-storage-download-urls-tokens https://www.youtube.com/watch?v=mVmIJ4hvTss...
No description

Variable is 0

Me doing matrix stuff and the minimum is 0 somehow.

App returning "Bad Request" before Controller method is called or ServiceFilter is triggered.

Hi I have an issue where I'm trying to send some user data to an endpoint from my frontend blazor server app to an api. Inspecting breakpoints tells me that the payload send is 100% correct. And the api call is made. But it only reaches somewhere before the whole controller. When I use a debugging Middleware I see that the request is made but it ends there. No more logs from inside the filter or controller method are logged and I just get the response bad request. Controller ```csharp [HttpPost]...

incorrect even if its the same data from the database

im doing the login form for my system but even if i input the correct record from my database the messagebox i created always say its incorrect. here's the code for the button `` string user = idtb.Text; string password = ptb.Text;...

Logical flaw in code

Basically the child paths of the folder is always missing the folder name of the folder being moved in child's new path's part even though the new path is only syntactically valid and it should not be missing it, also the unit test case passes even though it shouldn't. https://pastebin.com/G8rEt4xb...

Multi-rid restore/build

I am looking into publishing for both arm/amd64 and wonder if doing a multi-rid restore/build/test/publish is possible and if so how?

Is it possible to create a file outside the project folder?

A yes/no question basically. This is the code I currently use to create and store files. When the StoragePath is "uploads", it creates an upload directory within my project folder....

How to authenticate a chrome extension using blazor server

Our users sign in to the blazor app using the standard identity authentication with their own username and password. We want users to be able to authenticate themselves to use the chrome extension by being redirected to sign in to blazor app. There's so many different auth flows that I don't know what makes the most sense here. Is oauth2/openiddict overkill? We just need to get basic information about the user: name, email. As well as authorize them to use a couple endpoints that the extension uses. The authorization needs to be added in addition to the current authorization we use....

Pagination or no pagination

Hi i cant decide to whether implementing pagination or not.
I understands that pagination serves the client a subset of data to offload the computing of the backend. While this is great when x amount of client are request data from a table. The problem lies when they need to do the filtering, the filtering only happens on the subset instead of on the whole table. So if the table consist of 1000 records and the subset is 10, filtering only happens on the 10 records. ...

✅ Testing an abstract class

NOTE: Because SomeClass is an abstract class, you'll need to create a subclass in order to use most of this functionality. This ensures that the specific details associated with a given bank account type can be handled appropriately. i don't understand that, i have some tests to pass ( I can't modify them ) and they take SomeClass and try to make instance of it and test methods inside, how do i pass those tests?...

I need to open the new mail window from the new outlook and send an email from there.

I tried adding an OutlookAddin VSTO, but it seems like they’re not connected, even thought I added the project dependences. What should I do in this case, or do you have any other solution for this?

Can't authenticate via NTLM from Linux Kestrel hosted ASP.NET API to IIS hosted ASP.NET API

Hi! Context: I am trying to authenticate and do a request on an API that is hosted via IIS and that uses NTLM authentication (Active Directory Username and Password) The API im using to run the authentication + request is hosted on Red Hat Openshift (Linux) with Kestrel RUN apk add --no-cache krb5-libs krb5...

vscode c# debugging not working

i have a simple dotnet new blazor -int webassembly -n testapp app and i can not get it to launch with the c# devkit debugger it says i need to install chrome or edge, i dont want spyware in another app, exactly like above, i can just press f5 and it debugs fine, server starts, localhost runs. this app has no task/launch.json files, i am wondering why that one even runs?...