Questions tagged [asp.net-minimal-apis]
16 questions
                    
                    3
                    
            votes
                
                0 answers
            
        Correct way to sign out a user in ASP.NET Core Identity
I'm looking for the correct way to sign out a logged in user, when the sign out endpoint is called.
For example, the user logg is using the below method:
var user = await _userManager.Users
    .Include(u => u.UserRoles).ThenInclude(r => r.Role)
   …
        
        PeterPazmandi
        
- 533
 - 10
 - 13
 
                    2
                    
            votes
                
                1 answer
            
        Serilog Context Issues with Endpoints mapped in Static Class
This issue is driving me bonkers.
I'm not having an issue getting Serilog to output to a file.  I am having issues with Serilog enrichment when the endpoint is mapped within a static class and also in my Mediatr handlers.
This is the configuration…
        
        DerHaifisch
        
- 394
 - 1
 - 5
 - 14
 
                    2
                    
            votes
                
                1 answer
            
        How to add body parameter examples to OpenApi in MinimalApi
So we have minimal API implementation and would like to add swagger documentation for request/response.
What I don't know how to achieve is how to annotate request body parameters and responses with example values for the caller.
We are using…
        
        freshbm
        
- 5,540
 - 5
 - 46
 - 75
 
                    2
                    
            votes
                
                1 answer
            
        What is the correct lifetime for classes used to organize Minimal Api endpoints and should I resolve them in CreateScope()?
I am still learning and afraid of captive dependency (a dependency with an incorrectly configured lifetime). Consider the following code snippet and the full code is given at the bottom.
My objectives:
organize Minimal Api endpoints with endpoint…
        
        The Real Masochist
        
- 499
 - 4
 - 10
 
                    1
                    
            vote
                
                0 answers
            
        ASP.NET Minimal API transmitting ongoing stream
I have a stream that I'm consuming from a camera. The stream data is returned in a callback function and what I would like to do is create an API endpoint that will return this stream to the requester as long as the stream is streaming.
Not sure if…
        
        developer82
        
- 13,237
 - 21
 - 88
 - 153
 
                    0
                    
            votes
                
                0 answers
            
        Minimal API how to make FromBody accept both x-www-form-urlencoded and json?
Using ASP.NET Core 7 Minimal API:
[HttpPost("Create")]
public void Create([FromBody] User user)
{
}
Currently it is only able to accept application/x-www-form-urlencoded but I wish it can accept application/json as well.
        
        s k
        
- 4,342
 - 3
 - 42
 - 61
 
                    0
                    
            votes
                
                2 answers
            
        how to write asp.net minimal api optional parameter?
I wrote an endpoint which accepts MediaParams object which extends another param class and together they act like a wrapper for parameters and look like this:
public class MediaParams : PaginationParams
    {
        public string OrderBy { get;…
        
        Ruby Rain
        
- 105
 - 6
 
                    0
                    
            votes
                
                0 answers
            
        Minimal API service deployed to IIS does not work
I have a minimal api service deployed to IIS using Azure DevOps pipeline.
As the service does not work as expected (500 - Internal server error), I checked the IIS. I see that app settings cannot be read. IIS can see only the automatically generated…
        
        David Shochet
        
- 5,035
 - 11
 - 57
 - 105
 
                    0
                    
            votes
                
                0 answers
            
        Why is LinkGenerator.GetUriByName() returning null when template has constraints in Minimal Api handler
When I use a basic template
 serialNumberGroup.MapGet("{id}",async (....
 var link=linkGenerator.GetUriByName(contextAccessor.HttpContext, "GetSerialNumber", new {id}); 
The value of link would be the correct.
However if I use constrainst in the…
        
    
                    0
                    
            votes
                
                1 answer
            
        How to apply RequireAuthorization Attribute for list of endpoints in minimal API
Currently, I have applied RequiredAuthorization method on each endpoints as below
 endpoints.MapPost($"{ProductsConfigs.ProductsPrefixUri}", CreateProducts)
            .WithTags(ProductsConfigs.Tag)
            .RequireAuthorization()
           …
        
        sameer
        
- 1,635
 - 3
 - 23
 - 35
 
                    0
                    
            votes
                
                0 answers
            
        HTTP error with swagger ui with minimal API image uploader
I am attempting to use minimal api to develop an image uploader. I have the program.cs file code debugged and it launches to a webpage with an http 404 error. This is the entirety of the code.
using System.Text.Json;
using…
        
        Curtis Antisdel
        
- 21
 - 2
 
                    0
                    
            votes
                
                0 answers
            
        Dotnet 7 Minimal API swagger browser ui refuse to work
Strange issue. My swagger Browser UI (for development testing) is working. I am using port 5060 (in launchsettings.json, profile http), and due to testing requirement, I am changing to 5061, 5062 from time to time.
After many times of changes,…
        
        s k
        
- 4,342
 - 3
 - 42
 - 61
 
                    0
                    
            votes
                
                1 answer
            
        Settings the webroot path via appsettings.json in the new minimal hosting model
In the new ASP.NET Core 6 minimal hosting model, how do I set the webroot from the usual appsettings.{Environment}.json files (and all the other usual configuration sources the hosting builder sets up by default)?
When I do it via…
        
        bitbonk
        
- 48,890
 - 37
 - 186
 - 278
 
                    0
                    
            votes
                
                0 answers
            
        ASP.Net Core AddMiddlewareAnalysis
I have implemented Andrew Lock's version of using the AnalysisDiagnosticAdapter as he describes here https://andrewlock.net/understanding-your-middleware-pipeline-in-dotnet-6-with-the-middleware-analysis-package/
var builder =…
        
        docjosh
        
- 85
 - 1
 - 1
 - 8
 
                    0
                    
            votes
                
                1 answer
            
        In ASP.NET Core minimal API, how can you get the route name?
I would like to test the routing of a minimal API WebApplication. How can I get the route name, given a HttpRequestMessage?
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRouting().Configure(options => {});
var… 
        
        Cameron Taggart
        
- 5,771
 - 4
 - 45
 - 70