373 questions
0
votes
0
answers
49
views
Cannot find how to skip authentication middleware for specifics paths
I am working on a small ASP.NET Core 8 Web API using the Minimal API template.
I'd like to be able to skip my ApiKeyAuthenticationHandler for the health check (/health path) to avoid noise in the log ...
1
vote
0
answers
70
views
Using .NET 10 and SwaggerUI to handle complex data in a GET request
I have a simple .NET 10 Minimal API that I'm testing with SwaggerUI as :
public class Input
{
public string? StringVal { get; set; } = "";
public string[] ArrayVals { get; set; } = [...
Best practices
4
votes
2
replies
142
views
Is using #region acceptable to organize 30+ endpoints in a .NET Core Minimal API?
I have a .NET Core minimal API that has grown to 45+ MapGet/MapPost endpoints in Program.cs, and it's becoming difficult to navigate. All endpoints share several variables declared in Program.cs (...
3
votes
1
answer
88
views
Neat way to get request in Minimal API endpoint filter
In endpoint filters, I often want to get the request, for example FooRequest. I know there will be only one of these in the arguments list, so using GetArgument that requires passing an index integer ...
1
vote
1
answer
91
views
Connection is closed when accessing Minimal Web API
I have a WPF app that host a Minimal Web API. To start the Minimal Web API, the following code is used:
public async Task StartWebApi(IEnumerable<string> urls, CancellationToken token)
{
var ...
1
vote
2
answers
109
views
Replacing IServiceProvider in ASP.NET Core minimal API
I am attempting to migrate an ASP.NET Core application from using IWebHostBuilder to WebApplicationBuilder.
I understand that you can no longer call UseStartup.
One useful thing about the old model ...
0
votes
0
answers
68
views
How can I apply these attributes in F# ASP.NET minimal APIs?
I'm trying to convert this C# example from the .NET Minimal APIs Quick Reference that sets up a keyed service.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddKeyedSingleton<...
4
votes
1
answer
131
views
Minimal API: Dictionary<string, string> always null when sending data with IFormFile via multipart/form-data
I’m using ASP.NET Core Minimal API. I have an endpoint where I want to receive an IFormFile along with a Dictionary<string, string> property in the same request. I set the Accepts<...
1
vote
1
answer
80
views
Cant create a public class in app.MapGet in Minimal api app
app.MapGet("/bus_schedule", (string user_stop_name, string user_route) =>
{
public class Bus
{
public string[3] arrival_time { get; set; }
public string route { ...
1
vote
1
answer
51
views
OutputCache but still going into code in Minimal API
I am trying to get cache working on my API call but every time I do a request it goes straight into my lookup service code.
I have two services, stock and productlookup. The stock calls the ...
0
votes
1
answer
86
views
Minimal API: PageResult<T> not returning OData-style JSON with @odata.count and value
I’m building a .NET 8 minimal API endpoint that returns paginated results using OData. My service method returns a PageResult like this:
public async Task<PageResult<ItemDto>> GetItemList(...
0
votes
1
answer
105
views
Can I run ASP.NET Core Minimal API and Azure Functions in the same project locally?
I'm working on a backend that uses both ASP.NET Core Minimal API and Azure Functions (TimerTrigger and HttpTrigger). I want to run both locally for development and testing.
However, I'm running into ...
1
vote
1
answer
245
views
After publishing, Swagger loads but doesn't display any endpoint
During local development, my ASP.NET Core 8 Minimal API project is operating without any issues. Swagger opens at /swagger, all endpoints are visible, and everything is testable directly from the user ...
1
vote
0
answers
166
views
How do you turn off caching in a Minimal API?
I have written a Minimal API in C# running on .NET 8. It is supposed to return a single record and update a table in our database, indicating that a record has been processed. The nature of the ...
0
votes
1
answer
53
views
Blazor server connection disconnected error when sending Excel file as streamcontent to ASP.NET Core Minimal API endpoint
I am using Telerik Blazor TelerikFileSelect component to select an excel file and send it as a StreamContent to ASP.NET Core Minimal API endpoint. I do not see any issues when I send a 13 KB Excel ...
2
votes
0
answers
105
views
Validation and the required modifier
I'm working on an ASP.NET Core Minimal API. We are using the MiniValidation library for request validation on our endpoints. We have some strict linting that means for reference types we need to ...
0
votes
1
answer
163
views
ASP.NET Core minimal API route containing URL does not work behind IIS
I am writing ASP.NET Core 9 application using the minimal API. In this application I have a route that accepts an absolute URL as part of the route. This works when I run the ASP.NET application ...
2
votes
1
answer
553
views
Is there a way to use the same handler for multiple endpoints using Fast Endpoints?
I'm using fast endpoints in a .NET 9.0 web api project and I'm finding myself writing a lot of boiler plate to get the basic functions up and running. I'm writing just my basic database CRUD and I'm ...
1
vote
1
answer
204
views
Am I safe injecting an IHttpContextAccessor into an ASP.NET Core service?
I have a Blazor web app that uses minimal API endpoints for when it's in WASM rendering mode. These endpoints simply pass the request to server-side services that are called directly when in server ...
0
votes
0
answers
25
views
Why does SignInWithClaimsAsync return a token during login but not when switching tenant in ASP.NET Core Identity?
I'm using ASP.NET Core Identity with AddIdentityApiEndpoints<User>() and bearer token authentication configured via BearerTokenOptions.
In my login use case, I use the following:
await ...
1
vote
2
answers
170
views
How to Fix Model Binding of StronglyTypedId Struct in ASP.NET Core 9 Minimal API?
I'm building an ASP.NET Core 9 Minimal API where the endpoint I'm working on is receiving form data, but it is failing to bind the value of one of the properties. The property is a strongly typed id ...
3
votes
1
answer
406
views
How to use camel case in query string parameters name and OpenAPI on .NET 9 with Minimal API?
I want to have my OpenAPI json spec to use camel case in all query string parameters for my routes. So far the only way I managed to get this working was by using [FromQuery(Name = "camelCase&...
2
votes
0
answers
224
views
C#.NET xUnit v3 test with TestContainers and Respawn failing with timeout in Release mode but working in Debug
I'm encountering an issue with my integration tests that use TestContainers and Respawn. The tests work perfectly in Debug mode (and within seconds) but fail in Release mode with the following timeout ...
1
vote
3
answers
254
views
Why are Minimal API endpoints waiting for Tasks?
Building a basic ASP.NET Core Minimal API, I was surprised by the fact that if an endpoint returns a Task, the request does not return until the Task is done:
var builder = WebApplication....
1
vote
0
answers
238
views
ASP.NET Core 9 Minimal API : CORS errors even after configuration added
I created an ASP.NET Core 9 Minimal API that is consumed by an Angular app. Both applications are on a IIS site and the Angular app is calling the backend with http://localhost/api/.... Both are on ...
0
votes
1
answer
349
views
How to include path in server url element of OpenAPI spec generated from ASP.NET Core Minimal API application?
I have a C# / ASP.NET Core Minimal API app with Swagger generating an OpenAPI spec. In order to match the publish yml, I need to add a server with path and remove the path elements from individual ...
0
votes
1
answer
167
views
Visual Studio .http file returns 401 even though Authorization header is set for the request
I trying to consume a .NET Core Minimal Api endpoint, which is secured with Bearer tokens, via the .http client in Visual Studio.
I'm setting a valid Authorization: Bearer <token> in the request ...
1
vote
0
answers
249
views
Minimal API returns empty BadRequest response in production
I have created a .NET 9 minimal API for work and everything works fine while debugging in vscode / Kestrel but when I deploy the application to IIS 10, all of my BadRequest responses does not contain ...
-2
votes
4
answers
421
views
ASP.NET Core Minimal API with backgroundservice [closed]
I have background worker which implements BackgroundService. I added this service in the beginning of my program.cs with
builder.Services.AddHostedService<MyService>();
How can I get ...
0
votes
0
answers
164
views
Minimal API with Swagger not showing correct endpoints under version
I have a problem when I switch version in the swagger UI. I see endpoints not related to that version they are associated with. For example I have 3 endpoints under version 1 but 1 endpoint under ...
0
votes
0
answers
55
views
OpenIdConnect Blazor Firefox random signOut
We have our implementation of OAuth protocol in an ASP.NET Core 9 Minimal API. Everything works fine in Chrome and Edge. In Firefox (v 135) it works as well but sometimes (e.g 1 of 10 attempts) the ...
0
votes
1
answer
319
views
Issue with Kiota MultipartBody in TypeScript: "unsupported content type for multipart body"
I’m trying to send a multipart/form-data request to a minimal API using the Kiota-generated HTTP client.
Full scenario here.
When I try to call the post function generated by Kiota, I receive the ...
1
vote
0
answers
104
views
Data annotation validations and consistant error responses in FastendPointsHey
I am using Fastendpoints to build my apis. Can anyone help me achieve following 2 goals please? I have tried alot of things but failing.
I know Fastendpoints uses Fluent validation but I am sharing ...
1
vote
2
answers
558
views
Newtonsoft custom converter not called in .NET 8 minimal API
We have a version checker API that we're upgrading from .NET Core 3.1 to .NET 8 minimal API. It needs to be backwards compatible, but we have run into a problem.
Starting in .NET 6, the default JSON ...
0
votes
1
answer
250
views
Document query parameter with minimal API
I try to put some OpenAPI documentation on a query parameter in a minimal API, using RouteHandlerBuilder extension methods. I haven't manage to find any examples or documentation on how this should be ...
2
votes
1
answer
66
views
How to use appsettings.json in program.cs without warning "ASP0000 Calling 'BuildServiceProvider' from application code results in an copy ..."
I am building a .net minimal api with a lot of settings defined via appsettings.json.
But how to use this setting classes in program.cs without the compiler generating the warning:
ASP0000 Calling '...
2
votes
0
answers
107
views
how to make refitter use already existing DTOs
I am using refitter to generate the type safe api.
But refitter generates all the DTOs by itself, but I wannt to use an already exsisting nuget package.
I tried with :
refitter swagger.json --skip-...
1
vote
0
answers
454
views
ASP.NET Core: generating new endpoints at runtime
I'm looking for a solution to generate new API endpoints at runtime using ASP.NET Core 8. I'm open to generating controllers classes on the fly, using Minimal API or whatever other solution there is ...
0
votes
0
answers
183
views
How to pass query parameters to login page
I have an ASP.NET Core Minimal API with cookie authentication and I need to add some query parameters to login url when redirecting user to login page, so I can show user some hint on the login page.
...
2
votes
1
answer
281
views
How do I get my ASP.NET Core minimal API to return a 401 if the user is not authenticated instead of redirecting to the log-in page
I have an ASP.NET Core Blazor web app, which uses Identity for authentication. The server project's Program.cs contains the following (rather trivial) endpoint...
app.MapGet("/testapi-time", ...
1
vote
2
answers
346
views
How does Minimal API handle concurrent requests from multiple users?
Assume I'm using the following C# Minimal API endpoint:
private Calculator calcObj = new Calculator ();
app.MapGet("/calc", (int a, int b) =>
{
var additionResult = calcObj.Addition(...
1
vote
1
answer
141
views
What is the livetime of a HttpClient if the requests are not awaited?
I have a C# .NET 8 Minimal API application, which has one service using a HttpClient to communicate with a different API. The point is one request to my application triggers thousands of requests to ...
1
vote
1
answer
322
views
Issue when fetching data from the backend minimal API with CORS is setup-ed
As the title says, I set up a minimal WEB API in .NET 8 with CORS, and the routes seem to be working fine on the backend, and even tested the CRUD operations with the REST Client extension in VSCode.
...
0
votes
1
answer
49
views
Uploading files as part of a larger form submission in a single request (Minimal APIs)
I'm trying to upload documents via IFormFileCollection as part of a larger form submission (in a single request). Each document has additional metadata, such as document type, document name, and ...
3
votes
1
answer
168
views
Specify empty Content-Type for unauthorized requests in Swagger
In order to generate a complete swagger.json file, I specify all possible return statuses for my minimal .NET API methods, which look like this:
app.MapGet(rootPattern, async (MyDbContext db) =>
{
...
1
vote
2
answers
956
views
How to get list of all endpoints in FastEndpoints?
In our app we need to get list of all FastEndpoints endpoints at runtime.
Basically we need the following info for all endpoints;
GroupName (null if not belongs to any group)
EndpointName (Name of ...
0
votes
0
answers
70
views
Self signed certificate for Minimal API accepted by Curl but rejected by EDGE
Create the cert using Powershell
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName "localhost" -FriendlyName "localhost" -NotAfter (Get-Date).AddYears(10)
...
0
votes
1
answer
240
views
,Net Core 8Minimal API Self signed SSL deployment
I can do it with OpenSSL, but need to deploy this self signed certificate to many PCs, so that the web browser can communicate to a localhost executable. I can't ask each and every PC to install ...
0
votes
1
answer
1k
views
How to return a TypedResults.UnprocessableEntity in an ASP.NET Core Minimal API?
I'm trying to return an fffff from a Minimal API. When I set up the return type, I get a weird error:
the non-generic type 'IResults' cannot be used with type arguments.
public static async Task<...
1
vote
2
answers
470
views
How to combine Minimal API's Pipeline Branching with MapGet syntax?
Say I want to have 2 endpoints, /a and /b, while also utilizing the pipeline branching for both of those endpoints, for adding custom middleware for them.
The following code does not work:
var builder ...