373 questions
0
votes
0
answers
31
views
How to transfer a collection of pictures from react(axios) to ASP.NET Core server?
The problem is that I can't write a request to send an array of files to endpoint.
About the server-side: the project server is built on ASP.NET Core (Minimal API).
Endpoint:
public static ...
0
votes
1
answer
320
views
How to submit MultipartFormDataContent from Blazor Client Project to a minimal API in Server Project in .net 8?
I have created new project with Auto Render Mode using .net 8. There I have added an End point in the server project like bellow:
public static void RegisterUserEndpoints(this WebApplication app)
{...
1
vote
0
answers
638
views
ASP.NET Core auth error, when using custom Login code
I have a simple backend app. I have and endpoint called /notes for fetching notes. I have added RequireAuthorization() to it but I can't authorize the users. I have written the login and signup ...
3
votes
2
answers
514
views
Address not available after HttpRequest in Docker Container
So this is my setup:
.NET Minimal APIs running in a Docker Container
Keycloak running in a Docker Container
In the development environment of my minimal-Api I can make a Http Request against the ...
1
vote
0
answers
313
views
.net 6 System.IdentityModel.Tokens.Jwt different behaviour between 6.24.0 and 6.34.0
Due to vulnerability warning in most 6.x versions of System.IdentityModel.Tokens.Jwt, I upgraded to the first non-vulnerable release 6.34.0. Problem is, I receive bearer error="invalid_token"...
2
votes
1
answer
2k
views
Set system.text.json.jsonserializer globally minimal api
I'm using .NET 8 minimal API.
I want to set the system.text.json.jsonserializer globally.
i don't want to pass the defaultSerializerSettings each time.
public static T Deserialize<T>(this ...
0
votes
1
answer
1k
views
ASP.NET Core 8 Minimal API [FromForm] Binding of a Value Object Property
I'm in the middle of converting an ASP.NET Core 6 API app to be a Minimal API app. Now that ASP.NET Core 8 supports [FromForm] for object binding, I decided to take the plunge, but I'm running into ...
1
vote
2
answers
1k
views
How to automatically document TypedResults.Stream responses within NET 8 minimal API
I have the following route mapped in a Mininal API application:
app.MapGet("api/test", async Task<Results<PushStreamHttpResult, NotFound>> (bool fail) => {
if (fail) ...
4
votes
4
answers
2k
views
Excluding Swagger from YARP routing
I've got a use case where I want to host both an API and its frontend on the same port. I use YARP to do this.
So all requests to https://localhost:5001 will by default be routed to https://localhost:...
0
votes
1
answer
129
views
Is it possible to bind a checkbox value to a complex type in a Minimal API
The offical documentation suggests it is possible to bind the IsCompleted property of a Todo class as described below using form binding (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/...
1
vote
1
answer
681
views
Exclude property from form binding in .NET 8 Minimal API
In order to avoid using Tuple<,> and reduce the amount of types used when passing input models and optional validation errors I have included the List<ValidationFailure> from ...
1
vote
1
answer
101
views
Unable to replace AppDbContext settings for production with in-memory database for integration test
I have made a minimalized code to illustrate the problem at my github repo: https://github.com/suugbut/MiniTest/tree/main.
I am learning integration test to test my minimal api. I cannot replace ...
12
votes
3
answers
6k
views
Delegate 'RequestDelegate' does not take 2 arguments - ASP.NET Core 8 Minimal API
This is my Minimal API (.NET 8):
app.MapPost("check", async ([FromBody] UserClaims claims, ApplicationDbContext dbContext) =>
{
var result = await dbContext.Users.SingleOrDefaultAsync(...
0
votes
0
answers
174
views
.net 8 minimal api swagger Error in docker - uncaught TypeError: Cannot read properties of undefined (reading 'forEach')
I have a .net 8 minimal API with swagger running OK in VS 2022 but when I containerize the app, I get a blank page when I try to access the swagger page.
Here's how I set up swagger:
Here's the ...
0
votes
1
answer
734
views
ASP.NET Core [FromBody] and Minimal API unexpected return value in Blazor
I have here my Minimal API setup with ASP.NET Core versioning and Carter. PutMethod,PostMethod, and PatchMethod works just fine, but my GetMethod and DeleteMethod does not return the string.
This is ...
0
votes
0
answers
118
views
ApplicationInsights logs not collected for dapr service invocations
I have two .NET applications hosted on Azure Container Apps. Both applications are set up with the same ApplicationInsights instrumentation key, and I include the service when configuring them.
When I ...
1
vote
1
answer
491
views
NewtonsoftJson JsonProperty is not working [duplicate]
I'm using .NET 7 and Minimal API.
I would like to use NewtonsoftJson
and this is the class that I'm using:
public class FileNameRequest
{
[JsonProperty("some_name")]
public int ...
1
vote
1
answer
480
views
Retrieving FromBodyAttribute On Argument from Minimal APi - InvocationContext.Arguments
I am trying to write a c# MinimalApi EndpointFilter validator for ComponentModel DataAnnotations. What I have is working fine when passing in a type to validate against but I am trying to make it a ...
5
votes
2
answers
490
views
Is ASP.NET Core Minimal API beginning forward slash a must?
Is there any difference between:
app.MapGroup("") vs app.MapGroup("/")
app.MapGet("task") vs app.MapGet("/task")
When I did tests, they looked no different. ...
1
vote
1
answer
2k
views
InvalidOperationException: No authentication handler is registered for the scheme 'Identity.External'
I am stuck at Google authentication in .NET Core Web API project.
I am using Google as my external authenticator, everything is working fine except when the call comes back to my handler, an exception ...
5
votes
1
answer
1k
views
Problems with Microsoft Endpoint Explorer Generated .http File
I am following an MS Tutorial that creates a minimal API in ASP.NET Core 8.0 and uses Endpoint Explorer in Visual Studio 2022 to generate an .http file to test the API endpoints.
Code for the model:
...
0
votes
1
answer
1k
views
How can I create an example requestBody in OpenAPI using MinimalApi?
I'm trying to dynamically build a MinimalApi in ASP.Net Core application and I'm struggling with generating a requestBody example.
I tried to solved it like this:
.WithOpenApi(x =>
{
x....
1
vote
0
answers
970
views
Adding a CancellationToken to minimal API endpoints
I've got a SQL server table with 32 items, it does not grow.
Along with a basic stored procedure which selects them.
select * from Codes
Then there is a minimal API around the stored proc which just ...
0
votes
0
answers
86
views
K6 load testing reveals that the performance of ASP.NET Core Web API is significantly slower compared to the ASP.NET Core Minimal API
I try to test my application in 2 scopes
Default ASP.NET Core Web API weatherforecast
Default ASP.NET Core Minimal API weatherforecast
The test results are amazing!
ASP.NET Core Web API:
scenarios:...
1
vote
1
answer
1k
views
Minimal API delete with multiple params
It seems that the MapDelete expects a single id to be passed, but my situation, I need to pass a pair of ids. I thought passing a JSON object content would work but it doesn't. Having a POST to act as ...
0
votes
1
answer
623
views
Minimal API routing issue
I'm creating a minimal Web API.
I have defined two routes:
app.MapGet("/reports/{id:Guid}", GetReportById);
app.MapPost("/reports", CreateReport);
with corresponding delegate ...
2
votes
1
answer
1k
views
Minimal API - Define Swagger Header Parameters
I'm creating a minimal API using Swagger and C#. I can't really understand how i define the header parameters. Something like [SwaggerHeaderParameter("apikey", "description...")] ...
2
votes
1
answer
981
views
.NET6 minimal API: Manipulating response after .MapGet
I need to manipulate the JSON after each .MapGet() in the same way (apply some transformations).
I always thought that we can setup middleware on response pipeline as well as on request pipeline by ...
0
votes
1
answer
753
views
Override response description in Minimal API
I'm building a simple .NET 8 (RC2) Minimal API.
I have a simple endpoint that can return one of 3 status codes: 200, 201 or 404.
app.MapGet("/check/{name}", async Task<IResult> (string ...
0
votes
1
answer
629
views
I have a minimal API in .NET Core 6.0 using ADO.NET in a repository pattern
I'm utilizing a Minimal API with a Service which calls a repository in .NET Core 6.0. I want to be able to pass a connection string to my repository.
Here's the tree of my project:
The idea is the ...
1
vote
2
answers
3k
views
In .NET 6 Minimal API, how to return a 403 with html/text content
I am using .NET 6 minimal API. I have following simplified code which may return a file, HTTP 304 (not modified), or HTTP 403 (forbidden).
app.MapGet("/download", (HttpContext httpContext) =...
1
vote
0
answers
830
views
WebApplicationFactory: How to use .NET 6.0 WebApplication.CreateBuilder instead of older Host.CreateDefaultBuilder()?
I have successfully converted my web applications to start using the new WebApplication.CreateBuilder(args) method, but I am not managing to replicate this success in my tests using a custom (derived) ...
1
vote
1
answer
377
views
Calling an API recursively within app itself
Is there a way in Asp .Net Core to call my API recursively every 30 minutes?
The situation is the application and the app status payload is being passed at the same time. Some instances, the ...
1
vote
2
answers
2k
views
Fluent validator with minimal api endpoint never gets executed
I'm trying to implement fluent validation extension on minimal api endpoint project
but I cannot manage to make it work
the project is .net 7 version with
<PackageReference Include="O9d....
1
vote
2
answers
807
views
How would you validate emails in a minimal API project?
Using [EmailAddress] in a controller-based API is sufficient to also include email validation errors (as far as I know), however doing the same in a minimal API doesn't have that feature. A colleague ...
0
votes
1
answer
362
views
Using .NET Minimal APIs, how should I return the contents of an AWS S3 object request response stream?
I have an endpoint in my .NET 8 web api that I want to use to return 1 to 1 the contents of an S3 object which is a JSON file.
Using AWSSDK.S3, the request returns a response object with a stream to ...
1
vote
1
answer
1k
views
Minimal API BindAsync doesn't work .Net 6
I was trying to bind data manually using BindAsync and I followed the Microsoft docs and here is the link : Microsoft docs. But it doesn't work with me.
I have the following simple code
var app = ...
1
vote
1
answer
3k
views
How can I Inject Minimal Endpoint class in ASP.NET Core 7?
I am using ASP.NET Core 7 for a project in which I am using Minimal endpoints. In the default minimal endpoint project, the endpoints are directly mapped in the program.cs class like this:
app.MapGet(&...
1
vote
2
answers
1k
views
Some minimal API endpoints not returning values, warning "ASP0016 Do not return a value from RequestDelegate"
I have the following minimal API code:
routeBuilder.MapGet("/test", TestMethod);
routeBuilder.MapPost("/test2", TestMethod2);
...
public static async Task<IResult> ...
0
votes
0
answers
484
views
Unable to get Swagger UI working with Minimal API and OAuth2
I am trying to setup Auth on a new minimal API. The API needs to connect out to Graph API (using GraphServiceClient) which I have working.
I need to get security working for the API. I need to setup ...
1
vote
1
answer
3k
views
Microsoft.AspNetCore.Http.BadHttpRequestException: Failed to read parameter "xxx" from the request body as JSON
I have a React TypeScript application which makes a call to a C# ASP.NET Core 7 Minimal API.
The call from the React app looks like this:
const resp = await Client.post('https://localhost:7196/...
0
votes
1
answer
279
views
Can't change status code in custom middleware .net 7 minimal API
I'm writing a middleware to change status code to BadRequest when received business notification messages from my domain, but I getting the message "StatusCode cannot be set because the response ...
18
votes
5
answers
18k
views
Upload files to a minimal API endpoint in .NET 8
Edit: Code Repo here.
Also I'm aware that I can simply add .DisableAntiforgery(); to my API endpoint as explained here to make it work, but I'd like to do this the proper way.
I'm trying to upload a ...
2
votes
2
answers
2k
views
.NET Minimal API BadRequest response does not return the body
app.MapPost($"{root}/v1/AuthenticateUser"
, async Task<Results<Ok<GetTokenForResponse>, BadRequest<ErrorModel>>>
(HttpContext httpContext, IMediator mediator,...
3
votes
1
answer
1k
views
How To Respond With a JSON Body on 415 (Unsupported Media Type) in ASP .NET Core Minimal APIs?
If you call an ASP .NET Core Minimal APIs endpoint without a Content-Type header, you get an empty body response with status code 415. I need to handle this error and respond with some error JSON. I ...
1
vote
2
answers
2k
views
ASP.NET Core minimal API's and parameter binding -> QueryString into a POCO (like how a Body goes into a POCO)?
I'm trying to get my simple ASP.NET Core 7 minimal API to automatically bind the QueryString parameters into a single POCO.
Reference: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/...
1
vote
1
answer
2k
views
Fast-endpoints global headers in swagger for all endpoints
I am using fast-endpoints library for building a minimal API. I need to have two generic headers (name, tracking-Id) across all methods of all the resources.
To implement this requirement, I have used ...
12
votes
4
answers
12k
views
How to configure JSON deserialization options in .NET minimal API project
I have a .NET minimal API project, as described here. One of the endpoints accepts JSON in the request body, and this is deserialized automatically. The code looks something like this:
app.MapPost(&...
6
votes
1
answer
4k
views
Using razor pages in ASP.NET Core minimal API
I am using Minimal API in ASP.NET Core. I need to return a Razor page. Is there any way to do this?
I have added
builder.Services.AddRazorPages();
app.MapRazorPages();
in program.cs file. And I have ...
0
votes
0
answers
40
views
mysterious bug between c# minimal api & nodejs & react-native
Something is really weird happening on my development setup. I am developing for IOS but using react-native but something is happening which is weird.
If I boot the app in my device, and try to fetch ...