9,763 questions
1
vote
0
answers
52
views
How to prevent "Operation not supported" exception when making HTTP request from Cloud Run web instance?
I have an ASP.NET Core 8 Web API running in Google Cloud Run. It uses HttpClient to call another internal API exposed via a Google Cloud HTTP(S) Load Balancer.
The load balancer adds the following ...
0
votes
0
answers
31
views
Set controllers in Scalar to be in alphabetical order
I'm using Scalar locally to hit my Web API endpoints in place of Swagger. When they displayed in the left hand panel they are not in alphabetical order. I've tried Googling and also tried various ...
0
votes
0
answers
79
views
Bearer error="invalid_token", error_description="The signature key was not found"
Trying to use OpenAPI and Scalar to add authentication to an ASP.NET Core Web API.
When I call my authorised controller with my bearer token, I get this response message:
Bearer error="...
0
votes
0
answers
42
views
Why is my first PuppeteerSharp PDF generation GoToAsync call slower than subsequent callls?
I'm using PuppeteerSharp in an ASP.NET Core Web API service to generate PDF documents from HTML pages.
It's working really well but I've noticed that the first call is always significantly slower than ...
Best practices
0
votes
0
replies
41
views
Where to keep authentication while creating new Microservices using .net-core?
I want to setup new .net-core microservices app, which might have 5-6 services. In future will deploy it in ECS in aws.
Flow is like:
Internet --> Edge gateway --> BFF gateway---> ...
3
votes
2
answers
151
views
Prevent chunking in ASP.NET Core 6 Web API
I have a legacy ASP.NET Core 6 Web API program which I cannot update to a newer version for various internal business reasons. I am receiving a POST request and sending back a JSON response in the ...
0
votes
0
answers
42
views
RouteAttribute inheritance not working when defined in class from another assembly
I'm building an ASP.NET Core 9 Web API project. I have an abstract parent API controller in class library and a child in API - both define a route.
For the parent class, I use Microsoft.AspNetCore.Mvc....
3
votes
1
answer
118
views
ASP.NET Core Web API keeps exiting with exit code 0 (0x0) when debugging
I'm currently working on an ASP.NET Core Web API project solution that has the following three sub-project directories:
- API/
- Core/
- Persistence/
For my project, I want the Core to handle the ...
2
votes
1
answer
46
views
PendingModelChangesWarning When Starting API in Docker Container
I have an ASP.NET Core 9 Web API and database in SQL Server. I'm trying to run them in containers, and have the API connect to the database. I have been developing this locally for a while and ...
0
votes
1
answer
131
views
ASP.NET Core OpenAPI/SwaggerUI XML root collections "XML example cannot be generated; root element name is undefined"
I'm trying to use the XmlDataContractSerializerOutputFormatter and XmlDataContractSerializerInputFormatter (yes, I have tried XmlSeralizerOutputFormatter and XmlSerializerInputFormatter so I don't ...
Best practices
3
votes
10
replies
273
views
How do you guys create DTOs?
I'm trying to learn how to use DTOs. Should I use AutoMapper or Mapster? I have heard some say you shouldn't use AutoMapper with some reasons. Should I do things manually? And how would I go about ...
2
votes
0
answers
67
views
HttpOnly cookie set by ASP.NET Core 10 Web API not reaching browser when called via HttpClient from Blazor server
I have a Blazor server app that calls a separate ASP.NET Core Web API via HttpClient. When the user logs in, the API sets an HttpOnly cookie in the response. However, the cookie never appears in the ...
1
vote
0
answers
93
views
ASP.NET Core Web API : OpenAPI/Swagger Ui with custom authorization header
I'm moving a Web API project from .NET framework to .NET 10. While I have the project itself working, I'm trying to get documentation up and running with OpenAPI (Microsoft.AspNetCore.OpenApi 10.0.3) &...
0
votes
0
answers
27
views
ASP.NET Core (.NET 6) app works with dotnet run but hangs with no response when hosted on IIS (Plesk / Windows Server)
I'm having a problem hosting an ASP.NET Core (.NET 6) application on IIS (Windows Server, managed via Plesk).
The application starts correctly, but HTTP requests hang indefinitely (no response, no ...
Best practices
0
votes
2
replies
68
views
ASP.NET Core 8 Web API returns 415 Unsupported Media Type when posting JSON
I am using ASP.NET Core 8 Web API. I created a POST endpoint that should accept a JSON request body and return the same object. However, when I send a request from Postman with Content-Type: ...
0
votes
0
answers
77
views
EF Core tries to create the database every time it is run on docker compose
I have an ASP.NET Core 9 Web API project running with SQL Server. It has been developed so far locally, only with SQL Server running in Docker. I've decided to move the API project to Docker, ...
Best practices
0
votes
8
replies
128
views
.NET logging without passing an ILogger around
I'm trying to figure out how to implement Logging in my ASP.NET Core 9.0 Web API. I don't like having to inject a logger object in every service class, so have been exploring different ways of ...
1
vote
0
answers
44
views
EF Core startup migrations not applying when deployed to Azure
I am developing an ASP.NET Core Web API and have the following code in my Program.cs:
// Apply migrations / create database on startup
using (var scope = app.Services.CreateScope())
{
var logger = ...
0
votes
0
answers
58
views
Blazor Server client side authentication with gRPC
We are building an application where there are several components that must all work together that are not all entirely in my control.
First, a frontend written in Blazor Server that does some ...
6
votes
1
answer
144
views
ASP.NET Core 10 extra content returned on JSON result
I'm converting an existing Web API 2 / ASP.NET MVC 5 app to ASP.NET Core 10 MVC / Web API.
I'm able to return the JSON content, but if I look in Fiddler, there's extra data before and after the actual ...
0
votes
0
answers
63
views
Column t.Value does not exist
What I'm trying to do is I am returning a json array of generic table from postgres function and trying to catch that json in ASP.NET Core backend and then deserialize it in generic(of type which db ...
0
votes
0
answers
121
views
Serilog Tracing - Azure Monitor with Traces and mismatched spans
Our solution for logging and tracing in our ASP.NET Core 8 Web API uses SerilogTracing, and Azure Monitor.
Following the latest advice from this article, we are seeing spans/traces for the activities ...
Advice
0
votes
8
replies
126
views
Enforcing a 2 second delay on Web API call?
I was working on a server-side Web API issue where I needed to add a 2-second delay. However, my unit test was reporting the following error:
Error: Expected sw.ElapsedMilliseconds to be less than ...
5
votes
0
answers
2k
views
The type or namespace name 'OpenApiReference' could not be found (are you missing a using directive or an assembly reference?)
I'm using .NET 10. I want to add an authorize button in Swagger, but I am encountering the following error:
The type or namespace name 'OpenApiReference' could not be found (are you missing a using ...
2
votes
1
answer
98
views
Setting default endpoint in ASP.NET Core Web API
I have an ASP.NET Core 10.0 Web API that uses controllers. I want to set the default endpoint (controller/method) if user does not enter a specific endpoint URL.
I have an /about controller/endpoint ...
Advice
0
votes
5
replies
126
views
C# external http request response as streaming API-response
Our ASP.NET Core Web API needs to request data from an external web service (and no, the external web service cannot be called directly from the client) and return it without modification to the ...
Advice
1
vote
1
replies
221
views
Best practice on error handling in .NET 10+
The .NET ecosystem is evolving quickly. Lot of approaches to do something. First, we had middlewares for error handling. Now we have IExceptionHandler.
For an ASP.NET Core Web API, do you recommend ...
0
votes
2
answers
154
views
DevExtreme DataSourceLoader SQL Error "Conversion failed when converting date and/or time from character string" with EF Core
I am building an ASP.NET Core Web API with an Angular frontend using the DevExtreme DataGrid. I encounter a SqlException when trying to filter my grid by a date column:
Microsoft.Data.SqlClient....
Best practices
0
votes
1
replies
109
views
How to properly implement global exception handling in ASP.NET Core Web API to return consistent error responses?
I'm building an ASP.NET Core 8.0 Web API and want to implement global exception handling that returns consistent JSON error responses to clients, regardless of where exceptions occur in my application....
1
vote
0
answers
54
views
Visual Studio "Package Restore Failed" when scaffolding a WebAPI Controller with EF Actions
I've created an ASP.NET Core 8 Web API project. I've created a number of controllers over the last months that I've been working on this. I use the scaffolded controllers (API with EF actions) as a ...
2
votes
1
answer
322
views
DevExpress license not recognized in ASP.NET Core Web API Docker container despite following documentation
I'm trying to deploy an ASP.NET Core Web API that uses DevExpress components in a Docker container, but I'm getting licensing warnings during build and a "License Invalid" red banner on ...
0
votes
0
answers
50
views
OpenIddict 4.x ID2043 — Is it possible to support dynamic tenant subdomain redirect_uri?
I’m using OpenIddict 4.x with ASP.NET Core and the authorization code + PKCE flow for a SPA.
I want to support multi-tenant subdomains, where each tenant has its own frontend host, e.g.:
https://...
4
votes
1
answer
439
views
Built-in validation support for Minimal APIs
I am trying to implement the in the above-mentioned feature in my minimal API which is now supported with .NET 10:
add builder.Services.AddValidation();
Set the [Required] on a property in my object ...
0
votes
1
answer
184
views
ASP.NET Core Web API with repository pattern: how to get User.Identity in the repository class? [closed]
My ASP.NET Core Web API endpoint is used to get the data from a SQL Server database.
The controller calls the repository method, gets the instance of the domain class with the result from the database,...
1
vote
1
answer
85
views
Can auto-mapper transform the record into the single string value?
Having product-attributes relation (one to many)...
public class Product
{
public int Id {get; set; }
public string Code { get; set; }
public string Name { get; set; }
public List<...
0
votes
0
answers
93
views
I have controllers in ASP.NET Core and I need to inherit from the BaseController
I am working on an ASP.NET Core Web API, and I have controllers.
We have multiple controllers, and for every controller, we have common routing mentioned:
Route("api/[controller]")
Instead ...
0
votes
1
answer
90
views
Azure application with ASP.NET Core app service with Entra authentication
I've built an ASP.NET Core Web API, and I use the built-in Microsoft Entra authentication method (not the one from the App Service).
This app is deployed to an App Service on Azure. This App Service ...
1
vote
1
answer
80
views
How to Configure Azure AD and Azure AD B2C Together as JWT Authentication Providers in ASP.NET Core?
I am trying to configure dual JWT authentication in my ASP.NET Core Web API.
My API should accept tokens from:
Azure AD B2C
Azure AD (Entra ID)
I use a PolicyScheme (DualAuth) to auto-detect which ...
0
votes
1
answer
69
views
NLog.Web.AspNetCore not formatting object as JSON
I'm trying to log error objects as JSON in my ASP.NET Core 9 Web API. I am following the wiki in the NLog documentation: Structured logging.
I have NLog.Web.AspNetCore v6.0.5 as a dependency. In ...
1
vote
0
answers
49
views
Swagger Caching Authentication parameters
I have an ASP.NET Core Web API. I am using Swagger, so when I run my app in debug mode, the Swagger page appears and I can test my endpoints. I also have authentication, and crucially, I'm ...
2
votes
1
answer
124
views
ASP.NET Core 8 IProblemDetailsWriter fails when using [ProducesResponseType(typeof(T), 201)]
I have an ASP.NET Core Web API controller action that returns a 201 Created response with a custom type, and I also have a custom exception handler that writes ProblemDetails for 400–500 errors.
The ...
Best practices
0
votes
4
replies
82
views
Should I create navigation properties for BaseEntity's CreatedBy/ModifiedBy fields in Entity Framework Core?
I'm building an e-commerce application with ASP.NET Core Web API using Entity Framework Core and ASP.NET Core Identity. I have a BaseEntity class that tracks audit information (who created and last ...
0
votes
1
answer
118
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 ...
Best practices
0
votes
4
replies
671
views
Upgrading from .NET framework 4.8 VB.NET project to .NET 10
I have an application which was written years ago in VB.NET. Recently I migrated it to .NET framework 4.8. This change was smooth.
Now I am planning to migrate it to an ASP.NET Core 10 Web API using C#...
0
votes
1
answer
107
views
Using LibreOffice portable to convert Excel to PDF in an ASP.NET Core Web API (IIS and IIS Express for development)
I had used LibreOffice portable a while back to convert documents to PDF and I cannot for the life of me figure out how to do it again.
Every time I run this in IIS Express for development I am ...
0
votes
0
answers
70
views
How to add an existing Angular project into the same Git repo as my ASP.NET Core Web API (VS + VS Code setup)?
I am building a full-stack project where:
Backend: ASP.NET Core Web API (created in Visual Studio 2022)
Frontend: Angular project (created separately in VS Code)
Git: I initialized Git from Visual ...
0
votes
1
answer
161
views
How to configure multiple security schemes in ASP.NET Core Swagger with NSwag API spec
I have an ASP.NET Core 8 Web API with a Swagger page using Nswag + OpenAPI3. I also have an OAuth2 security implementation which is working great. Thanks to AspNetCoreOperationSecurityScopeProcessor ...
1
vote
1
answer
136
views
Unable to create a 'DbContext' of type 'AppDbContext'. The exception 'Object reference not set to an instance of an object.' was thrown
I'm getting this error :
Unable to create a 'DbContext' of type 'AppDbContext'. The exception 'Object reference not set to an instance of an object.' was thrown while attempting to create an instance....
3
votes
1
answer
97
views
HttpClient.PostAsJsonAsync (C#) returns 400 - string field is required
I have written an ASP.NET Core Web API method that works fine when testing with Swagger (on localhost in debug mode, while now the API has been published, and my URL is non-local).
The API entry point ...
Best practices
2
votes
3
replies
124
views
Callback in ASP.NET Core with auth cookies
We have a strong use case, and I’d like your suggestion on how to solve an issue we're facing.
We built a banking system using ASP.NET Core that allows users to view their accounts.
Here's how it ...