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
0 answers

Can I use domain-specific wwwroot folders in my project?

So I've been studying the documentation of.net Core Middleware and I'm working on a minimal Web API with an additional wwwroot folder containing static HTML content with CSS and Javascript. This is basically a demo for the Web API in the same…
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
0
votes
1 answer

Do I need context.Request.EnableBuffering?

To be clear: I want the HTTP headers AND body in case the request is invalid... I have an extreme minimal Web API in C# which looks like this: var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app .UseHsts() …
Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
0
votes
1 answer

Generate subtypes schema in swagger - Minimal Web API

I would like to display the subtypes classes in swagger documentation. my code: app.MapPost("/search", (BaseType t) => { return $"property: {t.p1}"; }); public interface BaseType { public int p1 { get; set; } } public class SubTypeA :…
0
votes
1 answer

Web Api Authentication without JWT (NET 7/ MAUI / minimal API: )?

I can't get the simple Web Api authorized request via JWT in NET 7 minimal API from a MAUI client app (see below). Therefore I thought of a workaround solution which looks like this: from the client side I also send the user data (user and…
user20081580
0
votes
1 answer

{culture} tag in route is not working for c# dotnet 7 minimal api

For API project with controllers, {culture} tag can be used to set the culture for the called api. When used like this swagger GUI asks for the culture separately. But when I use the same approach with minimal api, {culture} tag is not being…
uuctum
  • 15
  • 4
0
votes
1 answer

Do we need request handlers while we use minimal api endpoints?

Typically, when we want to have testable application logic, we usually create controller that can looks like this: [HttpGet] public IActionResult SomeAction() { var result = _someRequestHandler.Handle(); return Ok(result); } I think we do…
Szyszka947
  • 473
  • 2
  • 5
  • 21
0
votes
1 answer

How to query on SQL Server in .NET 6 minimal API by anything other than Id

I have a small database that has been created by EF using a typical model class: public class Metrics { public int Id { get; set; } public string? MetricValue { get; set; } public string? MetricHost { get; set; } public string?…
TyMac
  • 783
  • 2
  • 9
  • 32
0
votes
0 answers

Streaming a csv file to a console application -Whats going wrong(grpc)?

So i got this grpc client that streams data from a csv to a console and just prints it, in 1 minute it can do about 1.5mil records. On the other hand i got this minimal api, Now here begins the problem Im guessing I need to use httpclient to make…
AntiMatter
  • 13
  • 5
0
votes
0 answers

.NET 7.0 Swagger Parameter Documentation Issue With Minimal APIs (and .WithOpenApi() method)

It took me a long time to narrow this down, so I'm posting here to inform everyone of my findings as well as to try and determine if this is an actual issue that needs resolution (maybe I missed something obvious). Anyways, according to the…
0
votes
0 answers

Calling another API with .net minimal API

I am pretty new to .net and also minimal API's. I am trying to create a web API that calls another API. The Fuel Controller is the API that I will be calling and after dependency injection I am trying to call it with the app.MapGet() function…
svalaie
  • 73
  • 7
0
votes
1 answer

Setting up authentication endpoints class in minimal API

In Program.cs I have a post endpoint for getting a Jwt token: app.MapPost("/api/security/getToken", [AllowAnonymous] async (UserManager userMgr, UserLoginDTO user) => { var identityUser = await…
pușigreen
  • 91
  • 8
0
votes
1 answer

How to return an office document to OfficeOnline from WOPI API?

I am trying to use C# minimal API to develop a WOPI API for office online and on returning file to client i am always getting this error messages: "Timeout are not supported on this stream". I am using 'application/octet-stream' HTTP Header.
0
votes
1 answer

No having binding error when required property missing in minimal api

I am building a simple minimal api using net6. I am working with enable I have a simple model like this: public record MyModel(string Prop_1, string Prop_2); I have an endpoint defined as follows: builder.MapPut("/models/save", async…
0
votes
2 answers

Minimal API - multi-value parameters separated by commas to array of strings

I have query parameters such as /api/items?sizes=m,l,xxl, meaning they are separated by commas. I want to accept them as array of strings ([FromQuery] string[] sizes). How do I do that? I know how to split the string, the issue is how do I accept…
nop
  • 4,711
  • 6
  • 32
  • 93
0
votes
2 answers

Results.Ok(output) versus Results.Ok(await output.ToArrayAsync())

If I use // VERSION A private static IResult Gets(AppDbContext db) { var output = db.Courses.AsNoTracking().Select(c => new CourseDto { Id = c.Id, Credits = c.Credits }); return Results.Ok(output); } instead of // VERSION B private static…