electronic heartbreak.
Azurite to run in VS or Docker
As the title suggests I wonder if there are any tradeoffs whether I should use Azurite through the built-in Visual Studio method or to implement it through Docker?
The project is already configured in Docker, so maybe that's a hint it should be used through Docker too?
1 replies
Using IFormFile in Web API project results in network failure.
Hello everyone reading this thread,
As the title suggests, I am trying to upload an image using the
IFormFile
interface in a property. When I upload the image, the system 'crashes' and I get a network failure with the following message:
This is the only code I have added to a default ASP .NET Web API project:
Controller:
6 replies
How is Modelstate.IsValid triggered?
Hello!
I am reading this tutorial on how DTO's can be implemented with API's: https://dev.to/moe23/net-6-automapper-data-transfer-objects-dtos-49e
The process in this tutorial seems normal and you can easily follow along.
There are only 2 things I have my questions about:
1. The Driver class in this tutorial has no DataAnnotations (see first codeblock). How come the Modelstate.IsValid can be triggered in codeblock 2?
2. How does Modelstate.IsValid get triggered when a Dto is passed but it gets mapped to an entity?
91 replies
ASP.NET Core Web API byte[] issues
Hello there,
I am trying to accept a byte array in my API request:
Swagger is used to test the API. When I launch the project and open it in my browser I see that this property accepts a string instead of a byte[]. Googling this issue did not gave much information besides this SO-thread
https://stackoverflow.com/questions/77233543/call-an-api-with-byte-array-in-net-6
My question is if this is good enough or has anyone else faced similar issues?
15 replies
✅ Expandability of the ASP.NET WEB API - Mongo tutorial code
Hello there,
I am currently following this tutorial: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-8.0&tabs=visual-studio
This tutorial explores the integration of mongo and c#. What in this tutorial is done is that they set collection, database and connection in the
env
-like file. This means that when you have multiple collections you need to add them here and expend all the setting classes.
Another issue I see with this is that https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-8.0&tabs=visual-studio#add-a-crud-operations-service is not maintainable in the long run, becuase of this line:
Would an EF-like approach be more suitable? So you have a MongoDBContext class that holds the collections and DI this Context class into the Service classes?152 replies
Testing private methods
Hey there, I have the following code:
I want to unit test this code using NUnit, When creating a Setup and initializing the class these 2 methods are in, and trying to write a test for the
IsInputValid
I see that I cant test private methods. However, it feels needed to test that method. I worked around the issue doing the following, but this feel very ugly.
If you have a solution for this or adivce, I am curious to know!7 replies