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

Minimal lambda throws exception when uploaded to AWS

My local dotnet version is 6.0.400 and dotnet lambda --help shows version 5.4.5. I have scaffolded a test lambda project with dotnet new serverless.AspNetCoreMinimalAPI -n TestCalc. If I load this in VSCode and hit F5 it runs just fine; Giving me…
Matt W
  • 11,753
  • 25
  • 118
  • 215
0
votes
0 answers

.NET 6 Minimal API with proxy

I am creating a minimal API using .NET 6. This API calls another API, and I would like to capture that last call in Fiddler (or Postman). In old ASP.NET we did like this in the web.config:
Axel Andersen
  • 330
  • 4
  • 14
0
votes
2 answers

Preventing or suppressing Microsoft log entries?

I'm using .NET 6 minimal APIs for a web service. I have NLog configured and working well using "appsettings.json" by using this: builder.Services.AddLogging(loggingBuilder => { loggingBuilder.AddNLog(new…
Bradley Plett
  • 163
  • 1
  • 11
0
votes
1 answer

In Swashbuckle.AspNetCore, Swagger JSON and UI generated without content type when Results.Ok is used

When you define API end points like following both are same in functionality, app.MapPost("/todoitems", async (FileModel file) => { return file; }); app.MapPost("/todoitemsnew", async (FileModel file) => …
0
votes
2 answers

How to input generic objects from unit test to C# .NET 6 minimal web API setup? Or get test server working without minimal code?

I'm trying to update how the company I work in initialize ASP.NET web apps and web APIs. First of all, because in our older 3.1 .NET Core setup we have no way to access a test server, and have to run integration tests through a socket on localhost,…
0
votes
1 answer

How to perform POST using .NET Core 6 Minimal API in Azure Blob Storage

I am new to .NET and I have to perform this. Assuming we have the connection string and the Environment variable setup, could someone give me resources or code or guide on how to do it? I just need to upload a pdf file in Azure Blob Storage using…
0
votes
1 answer

HttpClient 400 bad request on PostAsync to endpoint after switching from Minimal API to MVC API

I started out with a .NET 6 minimal api which was working fine, however I needed some extra functionality, so I then decided to switch over to MVC style api. Since then, when my WPF app tries to call the endpoint using POST I get a 400 bad…
Skint007
  • 195
  • 5
  • 15
0
votes
3 answers

Unable to create an object of type 'AppDbContext' For the different patterns supported at design time

I'm trying to to create a minimal API. unable to resolve the below error. "Unable to create an Object of type 'AppDbContext'. For the different patterns supported at design time. due to this reason not able to do Migration. Program.cs var…
Thiyagarajan
  • 327
  • 1
  • 6
  • 21
0
votes
1 answer

Proxy Request with Minimal API

So, I'm being forced into creating a gateway by the fact that an API I want to consume in my Blazor WASM app doesn't play nicely with CORS. So I want to create the quickest, laziest gateway API I can. This is categorically not going to be used for…
ScottishTapWater
  • 3,656
  • 4
  • 38
  • 81
0
votes
0 answers

How does ASP.NET Core 6 bind handle responses when binding HttpContext to a handler?

I just ran into a major headache working on a site that uses ASP.NET Core 6 minimal APIs. public class GetUsersEndpoint : EndpointBase { /// public override WebApplication MapEndpoints(WebApplication app) { …
Chris
  • 27,596
  • 25
  • 124
  • 225
0
votes
3 answers

dotnet 6 minimal API circular serialization

I am new to dotnet, trying out dotnet 6 minimal API. I have two models: namespace Linker.Models { class Link : BaseEntity { [MaxLength(2048)] public string Url { get; set;} = default!; [MaxLength(65536)] …
Bogdan Kuštan
  • 5,427
  • 1
  • 21
  • 30
0
votes
1 answer

Use MVC's model binding from application code

As a sample of what I'm trying to accomplish, here in MapPost I'm manually parsing the body of the HTTP request. // Program.cs using System.Text.Json; var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); Type[] types =…
Leks
  • 21
  • 1
  • 3
0
votes
1 answer

Creating record for entity framework with relationships to other records : ASP.NET Core 6 Minimal API (SQL / Postgres)

I have two tables, Participant and Meeting, in an ASP.NET Core 6 minimal API project set up like this: record Participant(int id) { public string name { get; set; } = default!; public string title { get; set; } = default!; } record…
0
votes
1 answer

How to return different cache-control headers for different endpoints using ASP.NET minimal APIs?

I would like to return a different cache-control header value for different endpoints using ASP.NET minimal APIs. How do we do this without controllers? This can be accomplished using controllers as follows: using…
0
votes
1 answer

How to return a File in a different method than the main one?

I want to download a file via Results.File(). It works when executing it in the main method (app.MapGet), however returning it in a different method does do nothing. The line where it should send the file is executed in the Debugger, however it does…
Steven2105
  • 540
  • 5
  • 20
1 2 3
15
16