9,749 questions
0
votes
1
answer
48
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 ...
0
votes
0
answers
15
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 ...
1
vote
1
answer
52
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
69
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 ...
-4
votes
0
answers
33
views
After host ASP.NET Core Web API Swagger UI which is not display only 200 showing while I call this in Postman [closed]
I deployed a REST API in IIS, whuch is developed by .net core but I can't access the Swagger UI from the local as well as remote
Also, when I call the API using Postman or cURL, I only get a 200 ...
0
votes
1
answer
57
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
141
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
67
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
43
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
55
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
94
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
78
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
1
vote
1
replies
82
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 ...
0
votes
0
answers
69
views
Set HttpContext Response Cookie in Blazor without API
Issue with Auth princliples not being able to write to response in blazor app through an injected service
LoginModal:
@using Microsoft.AspNetCore.Components.Authorization
@using MtgDeckBuilderServices
...
0
votes
1
answer
59
views
"Response Content-Length mismatch: too few bytes written (0 of 152295)" When copying pages from a PDF to another using iText
I'm trying to read a PDF as MemoryStream, and copy pages from that PDF to a new one.
I'm using iText PdfReader and PdfWriter.
var ms = new MemoryStream();
using PdfReader pdfReader = new ...
0
votes
1
answer
141
views
How do I create connection string with App Registration/Service Principal for a Web API using EF Core app with SQL Server using Microsoft Entra MFA
I have a generic ASP.NET Core Web API that uses EF Core to connect to a SQL Server instance that uses Microsoft Entra MFA account.
The connectivity prompt for the SQL Server looks like this:
I have ...
2
votes
1
answer
184
views
XML output from ASP.NET Core Web API (Nautix compliant XML)
I am creating an ASP.NET Core Web API endpoint which will fetch XML output in the Nautix compliant XML. Despite the XmlAttribute set on the class, it does not return attribute in the output. Please ...
1
vote
1
answer
104
views
Add data for many to many by reusing the same data from table
Goal: apply data in the tables [Movies], [GenreMovie] and [Genres] in an efficent approach (high performance).
Problem: when you need to reuse the data that is already existing in the database by ...
1
vote
0
answers
68
views
Docker container routing to YARP fails in Aspire
I have a software solution where there is
an ASP.NET Core 8.0 Web API running on Linux inside a Docker container (edge-service), making HTTPS GET and HTTPS POST to
an ASP.NET Core 8.0 Web API (front-...
3
votes
2
answers
126
views
How to handle EF Core update + Azure Blob upload transactionally in a single request?
I'm building an ASP.NET Core Web API where I need to upload a file to Azure Blob Storage and update an EF Core entity in a single request.
The challenge is that EF Core supports transactions, but ...
1
vote
1
answer
53
views
How to debug and call .NET Core web API endpoints from USB connected Android device?
I'm trying to call my web API endpoints from Android device connected via USB, but I get this error:
failed to connect to /192.168.1.156 (port 7259) from /192.168.1.159 (port 41916) after 10000ms
...
2
votes
0
answers
91
views
.NET Core localization: Web API controller can't resolve IStringLocalizer<T> from another project
I want to centralize app text and send localized messages, including from background jobs (sending localized push notifications to users in their preferred language). So I need to be able to resolve ...
0
votes
1
answer
86
views
How can I send my refresh tokens via httponly cookie to standalone blazor WebAssembly?
I've been trying for a couple days to implement refresh tokens into my ASP.NET Core Web API, but to no avail.
I've currently got an ASP.NET Core Web API that allows someone to log in with a username ...
1
vote
1
answer
56
views
Skip dev-only .env file in prod
I got an ASP.NET Core Web API project. For credentials, I created an .env file which is an embedded resource and has Copy always set (I've also tried Do not copy).
As that file contains sensitive data,...
0
votes
0
answers
47
views
Render deploy of ASP.NET Core Web API works but endpoints no
I'm trying to deploy an ASP.NET Core Web API on render.com, but it isn't working. The logs say it's something in the connection string, but I'm literally copying and pasting, there's nothing wrong ...
2
votes
1
answer
124
views
How to allow large file uploads (>50 MB) in ASP.NET Core 6/7 Web API hosted on Azure App Service
I have an ASP.NET Core 6/7 Web API with an endpoint that uploads files using multipart/form-data. I want to allow files of 50 MB or larger.
I'm currently testing with cURL:
curl -X POST "https://...
0
votes
1
answer
214
views
Having problem, implementing basic rate limiting properly in an ASP.NET Core 8 Web API
I am trying to learn using basic rate limiting in an ASP.NET Core 8.0 Web API. I set 'permit limit' to 5, 'window' to 1 minute and 'queue limit' of 2.
At this juncture, let me tell you that I have ...
1
vote
1
answer
64
views
ASP.NET Core JWT token works on Windows but not on Mac [duplicate]
Today I ran into an issue with my Mac. I have an ASP.NET backend API which uses JWT authorization. It works completely fine on my Windows PC, but when I try to run it on my Macbook Pro M1 / Mac Mini ...
1
vote
1
answer
49
views
Telerik Report Generation Fails in IIS on Azure VM with OperationCanceledException
I have an ASP.NET Core Web API that generates reports using Telerik Reporting. The report generation works perfectly in my local development environment, but when deployed to an Azure VM with IIS, it ...
1
vote
0
answers
52
views
Serilog not logging after first request in ASP.NET Core Web API running as Windows service
I've been unable to figure this one out and am wondering if anyone has any ideas. This is an ASP.NET Core Web API running as a Windows service.
It will log to a file at the absolute path I specify for ...
1
vote
1
answer
71
views
How to handle error during customized scoped dependency injection
I have applied the multi-tenant location for EF Core database applying customize schema per tenant in my ASP.NET Core Web API project.
To do that the client send request through the API by setting ...
1
vote
0
answers
112
views
Where is /login handled in ASP.Net Core Web API?
I have an ASP.NET Core Web API. When I set it up, I used the built-in ASP.NET Core identity stuff because that was fast and got me directly into writing the meat of the API functionality. Now I need ...
2
votes
0
answers
85
views
How can I accept a number with a leading 0 in .NET Core?
I'm responsible for maintaining a public ASP.NET Core 8 Web API. One endpoint accepts POST data like this:
{
"xid": 12345,
"message": "Hello, world!"
}
On the ....
0
votes
1
answer
95
views
How to convert (SQL) VARBINARY hashed password and salt columns to String for ASP.NET Core Web API
In my SQL Server legacy User table, I have the following columns (which I cannot change):
UserName: VARCHAR(50)
PasswodsHashed: VARBINARY
PasswordSalted: VARBIANRY
This table has thousands of records ...
0
votes
1
answer
86
views
How can I build and publish a SPA web application in Azure Devops?
We have built a React SPA web application with an ASP.NET Core Web API. The SPA and the backend are both in the same solution. So far this hasn't caused any issues running locally. When I created the ...
0
votes
0
answers
483
views
GetSwagger does not have an implementation
I am getting the following error in the startup of my ASP.NET Core 9 Web API project:
System.TypeLoadException: 'Method 'GetSwagger' in type 'Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator' from ...
0
votes
0
answers
56
views
Extending Users Login Time
I'm working on a web project which using an ASP.NET Core 8 Web API in the backend and Vue 3 as frontend. Authorization process is handled with OAuth 2.0 and the app issues a token (valid for 10 ...
0
votes
1
answer
135
views
rsa.ImportFromPem(privateKeyString) throws strange error in ASP.NET Core 6.0 Web API [closed]
using (RSA rsa = RSA.Create())
{
rsa.ImportFromPem(privateKeyString);
byte[] dataToSign = Encoding.UTF8.GetBytes(signData);
byte[] signedData = rsa.SignData(dataToSign, HashAlgorithmName....
0
votes
1
answer
63
views
Why is my ASP.NET Core Web API not connecting to Elastic Cache Valkey
I am working on an ASP.NET Core Web API that is deployed to AWS. I am trying to integrate Elastic Cache using Valkey and working locally at the moment. This is my Program.cs:
using Amazon;
using ...
0
votes
0
answers
104
views
ASP.NET Core Web API returns 404 on all endpoints despite correct routing and configuration
##Program.cs
```
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.MapGet("/", () => "API is alive");
````
...
0
votes
1
answer
134
views
How to verify JWT tokens from Supabase in ASP .Net Core Web API?
I am trying to use supabase auth in my React with TypeScript and Vite frontend and it works there but when I try to access the API it is not able to verify the token and I do not undestand why? Is ...
0
votes
1
answer
61
views
Custom ODataSerializer not being picked up in ASP.NET Core 8 application
The app I'm working with has the below snippet in the startup.cs file:
services
.AddControllers()
.AddOData(options =>
{
options.Expand().Select().Filter().OrderBy().Count()....
0
votes
2
answers
148
views
How to map OData to correct endpoint in .NET 8.0 OData - Wrong Endpoint Called
We have an ASP.NET Core Web API which is running on .NET Core 3.1 which needs to be updated to .NET 8.0.
During the upgrade I noticed that a URI which maps correctly to one controller endpoint in .NET ...
1
vote
0
answers
60
views
ASP.NET Core 8.0 Web API not allowing me to get session objects when set from a fetch call using React
I have a React page that makes a request to stripe onboarding and stores the relevant data in sessions like this:
[HttpPost]
[Route("SignupSeller")]
public async Task<IActionResult> ...
0
votes
0
answers
126
views
How to make Dockerized ASP.NET Core 9 Web API trust self-signed signing certificate?
I have two ASP.NET Core 9 Web APIs running in Docker:
Identity API (OpenIddict server) – issues JWT tokens
Voucher API (protected resource) – validates JWT tokens using AddJwtBearer
Identity API ...
2
votes
0
answers
101
views
ASP.NET Core Web API ApiController request is null for POST but files parameter is available
In the code shown here, the PostFormData method receives the files parameter as it should but the Request object is null and I don't know why.
public class UploadController : ApiController
{
...
0
votes
1
answer
48
views
ASP.NET Core Web API not authenticating with Identity cookies from Blazor Server app
I have two ASP.NET Core applications:
Blazor Server app with Identity authentication (working correctly)
Web API that should share authentication cookies with the Blazor app
The API is not ...
0
votes
1
answer
160
views
Proper management of Database transactions across services - ASP.NET Core, EF Core
I'm currently working on an ASP.NET Core Web API project, using EF Core as my ORM.
I'm handling database access through a repository pattern for each entity. This mainly because my project makes use ...
0
votes
0
answers
52
views
.NET MAUI for Android in connection API localhost [duplicate]
I have a problem, I get this error
[0:] Connection failure: ERROR {0}
when using a connection in a .NET MAUI project for Android. I applied the Microsoft instruction for the case when the API works ...
0
votes
1
answer
99
views
ASP.NET Core 8.0 Web API makes endpoint call but response has an error [closed]
I have the website that has .html files and Javascript that uses Ajax request to an ASP.NET Core Web API that is running in Visual Studio on https://localhost:7286/, and the .html files are running in ...