Questions tagged [minimal-apis]

Minimal APIs were introduced in ASP.NET Core 6 and are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Minimal APIs were introduced in ASP.NET Core 6 and are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Answers for many question can be found in the documentation.

236 questions
0
votes
1 answer

My minimal ASP.NET Core Web API returns error 405: Method not allowed

I want to update a record by calling my api endpoint using the put verb but his returns error 405 method not allowed. My api endpoint: app.MapPut("/sirs/{Id}", async (int Id, SIRCContext db, Sir sirc) => { var record = await…
Sam
  • 69
  • 1
  • 7
0
votes
1 answer

Disabling CORS in Minimal API Ocelot Gateway

So the problem is that i have Blazor WebAssembly for a front-end, Making API calls through the Ocelot API Gateway but for some reason the CORS are failing but in Ocelot Gateway in Program.cs i have using Ocelot.DependencyInjection; using…
Cream
  • 33
  • 5
0
votes
1 answer

How to handle MultipartBodyLengthLimit in Minimal APIs with custom model binding from Form

My code is working, but I'm looking to see if I'm doing this in the 'proper' fashion. I have a Minimal API that supports file uploads but also I needed to pass required meta data along with the files, and since [FromForm] isn't supported yet, I did…
Terry
  • 2,148
  • 2
  • 32
  • 53
0
votes
1 answer

How to use automapper in minimal api?

I am trying to use automapper in my new minimal api's project that i connected with cosmos db. When i try to get all of my objects i get the error: "Missing type map configuration or unsupported mapping" what's wrong ? My CarRequests class: public…
Ptrk12
  • 15
  • 3
0
votes
1 answer

.NET 7.0 Change the webrootpath at runtime based on the Request.Host - How to get the host in webapplication builder

I have wwwroot folder organized for each subdomain as below. The application is based on .NET 7.0 and want to Use StaticFiles from different folders in webroot wwwroot -- folder1.abc.com --index.html --index.js -- folder2.abc.com …
0
votes
1 answer

How does .NET Core C# Minimal API fill parameters?

With minimalistic API how does MapGet automatically fill parameters from querystring? With minimalistic API the following is possible: var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.MapGet("api/Students/Grades",…
Sudip Shrestha
  • 441
  • 4
  • 12
0
votes
1 answer

How to Send Request from MInimaApi instance to another MVC instance

I'm trying to create API working by minimalApi service who can be accessible from public and can send GET/POST/PUT request to my Web Service with Controllers. But every time when I Send GET to my controller, I receive status code 200 (OK) even when…
Igor Markiv
  • 147
  • 12
0
votes
0 answers

Multiple commands in CQRS MediatR question

I use Service - Repository pattern. I keep all basic CRUD in all repositories and won't touch/change. Service is empty and it's only for functions that are customized. So when I want to execute few actions, I create and customize like this in…
Asherguru
  • 1,687
  • 1
  • 5
  • 10
0
votes
2 answers

.NET Core 7 minimal post body logging

I'm using .NET Core 7, Minimal API and I would like to log POST request body. I use following code: var endpoints = app.MapGroup("api/v1") .AddEndpointFilter(); endpoints.MapPost("/endpoint", async…
Pavel
  • 653
  • 2
  • 11
  • 31
0
votes
1 answer

I could use a app.UseWhenElse() method, but it does not exist. Is there an alternative?

This would be interesting: app.UseWhenElse( context => context.condition(), applicationBuilder => { /* Condition is true */ }, applicationBuilder => { /* Condition is false */ } }); This would allow me to do conditional routing based…
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
0
votes
1 answer

Can I make the browser play an MP3 instead of downloading it?

This is a bit tricky. I have a Minimal Web API with this function: app .MapGet("/Speak/{name}/{*text}", (HttpContext context, string name, string text) => { string mp3Name = $"{name} {DateTime.Now:yyyyMMdd HHmmss}.mp3"; …
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
0
votes
1 answer

I'm getting a transient failure with MySQL and MariaDB

I am working on a simple Web API that uses MySQL as database. It's pretty basic: var builder = WebApplication.CreateBuilder(args); builder .Services .AddDbContext(options => { options …
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
0
votes
1 answer

Best way to access a DBContext from the middleware?

I have this: app .Use(async (context, next) => { await next(); StatusCode(DB.AddRequest(context, context.Response.StatusCode < 400)); }); Basically, this code is just adding some HTTP context information to a (MariaDB)…
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
0
votes
1 answer

Issue with IsApiVersionNeutral in asp.net minimal api versioning

Hi I am trying to implement versioning in asp.net core minimal api (net7.0). But I am seeing some url access issues with certain api versions. Hope someone can give me some clarity about why the urls are throwing 404 below. I am trying to build…
SanjayD
  • 156
  • 4
  • 12
0
votes
0 answers

dotnet convert controller route api to minimal web api

I am trying to convert a route from an old controller based api to a new dotnet7 api, however for some reason the temporary endpoint is not being hold. The basic idea is to create a temporary endpoint inside the main endpoint, and if no one calls…
thelittlemaster
  • 157
  • 1
  • 8