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
322
questions
0
votes
0
answers
26
views
AspNetCore Minimal API How Catching Error Binding Parameters?
I use .NET 8 and I have minimal API in ApsNetCore. I have this GET method with param bindings using StronglyTypedId:
internal static async Task<Results<Ok<PaginatedList<TestResultDto>&...
1
vote
1
answer
62
views
From a minimal ASP.NET Core Web API how do I return a JObject while maintaining the nested elements?
I am building a minimal ASP.NET Core Web API. One of my endpoints needs to return data contained in a JObject. This JObject represents a complex nested data structure. What I am finding is that the ...
-2
votes
0
answers
41
views
Most simple and secure authentication method for blazor app and web service
I'm trying to create a blazor web app with an external dedicated API service that should also provide authentication for both app and service.
Some specifications:
none of the app pages will be ...
1
vote
1
answer
55
views
Status code http 500 in .NET Core Minimal API, EF, SQLite. Works locally but doesn't work on Azure
I built a Minimal API using EF, Sqlite and C#. It works locally, but once I deploy it to Azure, I get a http 500 status code and a SQLite error that the table doesn't exist. I don't know if it doesn't ...
-1
votes
2
answers
129
views
ASP.NET Core 8 Minimal API throws 404 on deploy in IIS
When I publish my ASP.NET Core 8 Minimal API project using these settings:
Configuration: Release
Target framework: net8.0
Target runtime: Portable
on IIS on a Windows Server 2012 R2, I always get ...
1
vote
1
answer
69
views
Asserting IResult when retuning an Anonymous Type
I am learning Minimal APIs (and also still learning C#), but just got stuck when creating Unit Tests. Given this function:
public IResult GetGenderById(Guid id)
{
var gender = this....
0
votes
1
answer
112
views
.NET 8 Minimal API return JSON string as Json without first deserialize into an object
If I have a string (which is already in JSON format) say
string JsonStr = "{ 'A': 123 }";
My API is
public JsonResult OnGetRetrieve()
{
string JsonStr = "{ 'A': 123 }";
...
1
vote
2
answers
64
views
What is the different between .NET Minimal API and .NET AOT and how does it relate to each other if they are?
I have search on the internet and I couldn't find a concrete explanation regarding this. I have used Minimal API before and when I am using the .NET AOT, the project source code seems different except ...
1
vote
1
answer
189
views
ASP.NET Core Minimal API redirect that changes uri
I've done a couple of hours of searching after some failed attempts, and I'm hoping someone can provide a little clarity.
In the olden days, response.Redirect could be used in a web application to ...
0
votes
1
answer
61
views
How to handle separate authentication for mixed Blazor Server App and Minimal Api
I would like to combine a blazor server app with a minimal api as additional option for users to access data.
The blazor app uses windows authentication:
builder.Services.AddAuthentication(...
0
votes
1
answer
26
views
404 NOT FOUND error when calling endpoint with required claim
I have the following setup:
var services = builder.Services;
services.AddAuthentication(IdentityConstants.BearerScheme)
.AddBearerToken(IdentityConstants.BearerScheme);
services....
0
votes
1
answer
67
views
.NET Core json response differences between Chrome and Firefox
I wrote a Minimal Web API with this code:
app.MapGet("/api/getLogs", async (HttpContext context) =>
{
context.Response.Headers.ContentType = "application/json";
data =...
0
votes
1
answer
154
views
Set the same 'Produces' response for all Minimal API endpoints
in .NET 8, in a project with a minimal API, is it possible to set status codes, for example, 401 Unauthorized, on all endpoints with a single call to a method, for example:
app.MapGroup("test&...
0
votes
0
answers
94
views
Visual Studio 2022 Publish Fails - Unable to delete files
I am trying to Publish a sample DotNetCore project (from the basic VueJs/Core solution template) to an IIS server with the 'Delete Existing Files' option. If the app has been running, then the Publish ...
0
votes
1
answer
131
views
.NET 8 Minimal API - Finding Endpoints using NSwag that use AddEndpointFilter
I am using currently using AddEndpointFilter for my endpoint using MinimalAPI
app.MapGet("/{Id}", Method).AddEndpointFilter<HeaderFilter>()
Using NSwag's OperationProcessor, I want to ...