minimal-apis Questions
4
Solved
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(...
Cockloft asked 15/9, 2023 at 7:51
4
Solved
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...
Hornmad asked 27/9, 2023 at 18:22
2
Being able to customize the Host configuration in integration tests is useful to avoid calling services that shouldn't run at all during testing. This was easily achievable using the standard Start...
Narcoanalysis asked 19/6, 2022 at 17:57
1
Solved
I am porting an application from Asp.net Controllers to Asp.net Minimal-Apis. The current project is using model-based DataAnnotations. Controllers do model validation out of the box but MinApi doe...
Saied asked 18/2 at 4:15
2
Solved
This is my Minimal API (.NET 8):
app.MapPost("check", async ([FromBody] UserClaims claims, ApplicationDbContext dbContext) =>
{
var result = await dbContext.Users.SingleOrDefaultAsync...
Carbamidine asked 6/1 at 8:6
0
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 (deriv...
Unreflective asked 2/11, 2023 at 10:18
2
Solved
I am using a Minimal API to recreate an old REST service and so I need to mimic the functionality of the previous service as close as possible. Information in the old service is returned Pascal cas...
Billfish asked 20/9, 2022 at 13:54
7
Solved
In .NET 6 it is possible to create minimal APIs:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/products/{id}", (int id) => { return Results...
Franck asked 27/11, 2021 at 23:2
1
Solved
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 ha...
Anabas asked 7/9, 2023 at 8:30
1
Solved
I'm working with .NET minimal APIs and have encountered a problem with JSON serialization/deserialization behavior for enums. Despite my attempts to change the behavior to use strings instead of in...
Apocynaceous asked 8/7, 2023 at 15:55
2
Solved
I'm writing some middleware for an ASP.NET Core 7 minimal API project.
At this stage, I would just like to be able to read the request body being sent in, and then the response body that is being s...
Iover asked 23/5, 2023 at 16:24
1
Solved
I would like to add examples of answers for my endpoints in my minimal API in .NET 7.
I have already found several interesting resources but none of them work in the context of a minimal API:
http...
Wanderlust asked 17/5, 2023 at 12:50
1
Solved
In minimal API I define this endpoint that accepts DateOnly parameter:
app.MapGet("/info", (DateOnly date) => $"{date.ToString("yyyy-MM")}";
By default swagger jso...
Encratia asked 14/4, 2023 at 14:12
1
Solved
I created the following class:
public static class PingEndpoints
{
public static void Endpoints(this WebApplication application)
{
var group = application.MapGroup("ping");
group.Map...
Hippomenes asked 5/4, 2023 at 11:21
3
Solved
I'm working on minimal api, what I'm trying is when the user visits /download it immediately downloads my picture named add.png.
But no matter what I try it doesn't work because I either get an emp...
Pinite asked 4/1, 2022 at 13:27
5
Solved
I have a small project in .NET 6 that contains minimal APIs like that one
app.MapGet("/clients",
async (IClientRepository repo) =>
{
var results = await repo.GetClientsAsync();
ret...
Ritz asked 21/1, 2022 at 10:44
4
Solved
I want to create a simple file upload endpoint in ASP.NET Core 6 and thought it would be as easy as described here https://dotnetthoughts.net/handling-file-uploads-in-openapi-with-aspnet-core/.
Whe...
Lovellalovelock asked 16/3, 2022 at 15:4
2
Solved
If I have a json string (eg. read from a file) and my api returns as string, Postman will treat the response as text
app.MapGet("/myapi", () =>
{
var json = File.ReadAllText("fil...
Sparling asked 31/1, 2022 at 8:29
4
Solved
I created an asp.net core empty project and whenever I am trying to run my application it gives me the error shown below. I cannot even hit the end point as soon I hit play it gives the error.
Syst...
Merbromin asked 24/3, 2022 at 21:53
1
Solved
I've got a minimal API with a POST request /query expecting a raw json to search in mongodb
app.MapPost("/query", async (HttpContext context) => await FreeQuery(context));
FreeQuery i...
Borras asked 1/11, 2022 at 9:37
1
Solved
I use this link from microsoft https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0 to create my web api.
after that, I add the database like this:
var builde...
Corded asked 7/6, 2022 at 23:6
2
I have seen a number of similar questions but none seem to represent exactly the issue I am facing. When I create a folder structure as follows:
./
./src
./src/test
Then navigate to ./src/test and...
Blinni asked 29/3, 2022 at 22:31
0
Overview
We're moving our database access to API calls and I need to return search results from a database as they're being found using that API. The plan was to use IAsyncEnumerable, but I'm havin...
Diffractive asked 2/4, 2022 at 15:6
1
Solved
Using the .NET 6 Minimal API, I'm trying to handle multipart/form-data in the POST method. However, with the following code:
app.MapPost("/tickets", async (IFreshdeskApiService s, [...
Queeniequeenly asked 9/2, 2022 at 9:34
2
Solved
For some reason, foo always returns an empty body:
internal static async Task<string> Foo(HttpContext context)
{
var response = await Task.Run(() => { return "response"; });
re...
Satisfactory asked 2/2, 2022 at 22:30
1 Next >
© 2022 - 2024 — McMap. All rights reserved.