Questions tagged [asp.net-web-api]
ASP.NET Web API is a framework for building HTTP services for clients like browsers and mobile devices. It is based on the Microsoft .NET Framework and an ideal choice for building RESTful services.
37,835
questions
0
votes
0
answers
19
views
Migrating complex web app from .NET 4.7.2 to .NET 6
I have a working web app running on .NET 4.7.2, and I need to migrate it to .NET 6.0. I've been facing many problems in changes how .NET Core manages Http libraries and networking.
In particular I'm ...
-1
votes
0
answers
15
views
How can I save my Refresh Token to database on .Net7
I want to save my Refresh Token but its not work. I am asssigning string.Empty on user model and I am working on when user logged in update to database. I think refresh token generator is working fine ...
-1
votes
0
answers
18
views
Why I can't see ApiController's public methods and how can I fix uri?
I am using Unity Engine and I created a apı controllor for saving game data to there.I solved this system a little more, but now I encountered another problem. The problem is that I cannot see the ...
0
votes
0
answers
18
views
Creating Middleware in Blazor WASM To Capture Page Events
I have a Blazor WASM Core Hosted Application (three projects: Client, Server, Shared) using .Net 7. I am trying to create an audit trail feature in my Blazor WASM Core Hosted Single Page App. Ideally,...
0
votes
0
answers
13
views
Receive json by API with OAuth2
I have an application where I receive JSON data. My application is a web service written as an ASP.NET Web API (running on the .NET framework). My application lives on a Windows server.
I have used ...
0
votes
0
answers
10
views
AddSwaggerGen - create object in swagger.json for not used DTO
I use services.AddSwaggerGen() to create a swagger.json:
services.AddSwaggerGen(c =>
{
c.CustomOperationIds(apiDesc => {
if (apiDesc.TryGetMethodInfo(out var methodInfo)) {
...
0
votes
0
answers
31
views
What is the relationship between System.IdentityModel and Microsoft.Data.SqlClient?
I'm using old code for JWT validation, and the reference to System.IdentityModel throws an error unless I add the Microsoft.Data.SqlClient dependency.
I would like to know why this happens.
private ...
0
votes
0
answers
37
views
ASP.NET Cookie & JWT Hybrid Authentication
The application is setup to authenticate users using external login providers resulting in a standard ASPNET identity cookie which is used to authorize all non-API endpoints. API endpoints use JWT ...
0
votes
0
answers
63
views
Can I get the HttpContext from a Health check in C#?
I have implemented Health checks in ASP.NET Core with a custom health check. In my class which implements IHealthCheck, I inject IHttpContextAccessor. This resolves correctly, but when I try to access ...
0
votes
0
answers
96
views
How to fix the update problem in concurrent request in ASP.NET Web API 2
I am working on an ASP.NET Web API 2 project with .NET Framework 4.6.2. When I send two concurrent requests with the same parameters from Postman, only one record is updated in the database, even ...
0
votes
1
answer
45
views
Returning a list containing a mix of null items and non-null items
I'm building an API endpoint which takes in a list of requests and returns a list objects. What I want is get an empty list sent to the method caller if the results list contains just one item and the ...
0
votes
1
answer
36
views
How to send the pdf file through C# ASP.NET Web API
I need to send the PDF file stored on the server side through ASP.NET Web API, and I have to show at client side using Angular. And I also need to show the preview first before giving downloading ...
-1
votes
1
answer
26
views
How to properly implement JWT based authorization with ASP.NET Core 7 and Carter library and removing the lock on Anonymous endpoints
I have a simple minimal API configured with the help of the Carter library as following:
public void AddRoutes(IEndpointRouteBuilder app)
{
// Group for /api/user endpoints
var group = app....
0
votes
1
answer
26
views
Custom Datetime culture localization in .Net
I am working on a .Net web api project v6.0 and now I'm running through a serious problem.
When I have DateTime or DateOnly variables, .Net takes out -3 or more hours and messes up all the date for ...
0
votes
0
answers
18
views
Token Base authentication returns 401 unauthorized response in Blazor WASM
I'm developing a new project using Blazor WASM and an API and using token-based authentication for my project. But something interesting happened in the project and I decided to share it with you guys ...
0
votes
2
answers
83
views
Xamarin android app on emulator cannot fetch data from locally hosted asp.net core webapi: operation cancelled
I am developing an Android app with Xamarin forms that gets its data from a ASP.NET core webapi.
But so far, it seems to stop working at the following line:
HttpResponseMessage response = await client....
0
votes
0
answers
17
views
OData8 Swagger Request too long (ASP.NET Web API)
So I have setup OData in my Web API and it is working fine in postman as in making requests etc.
However, in swagger it shows a crazy amount of options and those are being applied to my request URI.
...
0
votes
0
answers
12
views
Getting 409 conflict error in OAuth 1 when using an API in C#
I'm trying to consume my client API which using an OAuth 1 authentication. I successfully consumed request token and Access token API. So now I have access token.
After that I consume 1 client API in ...
0
votes
2
answers
43
views
What is best practice for many to many relationships in ASP.NET Web API?
For my ASP.NET Web API, I have a many-to-many relationship similar to this:
public class Book
{
public int Id { get; set; }
public string Title { get; set; }
public Author Author { get; ...
0
votes
0
answers
28
views
Swashbuckle IExampleProvider showing array within array for List<T> parameter
I have a ASP.NET Framework (4.8) web API endpoint that accepts a parameter of type List<T> (simplifed method decoration with Swagger response/operation omitted for brevity):
[HttpPost]
[...
1
vote
0
answers
23
views
Purging output cache in .NET minimal API has no effect
In a .NET 8 minimal API I've implement output-caching on one endpoint (in a Carter module).
const int cacheDurationInMinutes = 10;
var clientGroup = app.MapGroup("/api/v{version:apiVersion}/...
0
votes
1
answer
29
views
Can't get imageUrl
i try to upload and get image in webapi net core but when i get imageUrl it don't run even i use app.UseStaticFile()
In Program.cs I use app.UseStaticFiles();
Code Upload and get Image
[HttpPut("...
0
votes
1
answer
37
views
Minimal API routing issue
I'm creating a minimal Web API.
I have defined two routes:
app.MapGet("/reports/{id:Guid}", GetReportById);
app.MapPost("/reports", CreateReport);
with corresponding delegate ...
0
votes
0
answers
48
views
How to write an API in C# that does not return all the data in a table at once to the client side
I have some basic react.js knowledge. I need to write an API in C# that will pull data
from a table and display in a KendoReact data grid. I want to be able to do filtering, sorting and pagination.
...
0
votes
1
answer
34
views
Connection error when sending web requests on unity WebGL build only
I'm trying to send a post request to my login API (located on same system) that I made on ASP.NET in c# with my unity WebGL build as client, but for some reason it always pops out a connection error ...
0
votes
0
answers
26
views
Restricting API access to only server-side app?
I have an API that would be accessed by another API which is then consumed by a front-end app. So [Web Page] -> [Middleware API] -> [My API]. Is there any way I can make my API private so that ...
0
votes
1
answer
86
views
Web api is translated to the wrong port specified in launchSettings.json
If I launch the web api from visual studio, it accepts requests at the address and port I specified in the launchSettings.json file. But if I run the application not from IDE, but via .exe, the api is ...
0
votes
0
answers
22
views
ASP.NET Web API : iterating over sections of multipart/form-data
ASP.NET Core has a library class for iterating multi-part forms MultipartReader.
I would like to iterate multi-part forms in an older ASP.NET Web API (.NET 4.8) in a similar fashion.
There is ...
0
votes
0
answers
29
views
How to throttle API requests by parameter in asp.net core
I have an API like this:
ActionResult GetReport(Guid id)
Now we do serve data from the cache if available. If not, we fill the cache (by id) and then return from it - this however is a very long ...
0
votes
1
answer
63
views
DTO validation attribute does not work with swagger MapType
I have dto with TimeSpan property.
[TimeSpanValidation]
public TimeSpan Effort { get; set; }
I needed to fill post request's body so I could enter this property. I ended up using MapType:
builder....
0
votes
1
answer
133
views
Authentication in Azure DevOps Server using Windows Auth
I don't understand how authenticate to Azure DevOps Server using Windows Auth.
I create a ASP.NET Web API project that identifies users using Windows Auth (https://learn.microsoft.com/en-us/aspnet/...
-1
votes
0
answers
7
views
User unable to fetch employeedetails when included [Authorize] attribute for employee controller
User logged in successfully using bearer token but when clicked on loademployees btn unable to fetch employee records instead status code received as 401-unauthorized. Here's the code for Data.html
...
0
votes
1
answer
76
views
Role Claim not working in ASP.NET Core 8 Web API after upgrading to .NET 8
I have a .NET 7 ASP.NET Core 7.0 Web API project which uses .NET 7 ASP.NET Core 7.0 IdentityServer4 Project. Everything is working fine.
Here is my code setup:
IdentityServer4:
In my ProfileService in ...
0
votes
0
answers
9
views
.NET WebAPI refuses to serve responses from fetch requests (nginx setup)
I'm hosting this on a Windows machine. I have a frontend and backend served through nginx with the following configuration:
server {
listen 80;
server_name my.website www.my....
0
votes
0
answers
29
views
Can I use grpc for kind of messages stream between 2 services?
I have a versioned data stored in a DB. Consumer request event data for a version, as event can have multiple versions consumer keep requesting for newer version on event data.
There are 2 services, ...
0
votes
0
answers
21
views
Tracking and Logging Changes in Backup Addresses with Entity Framework .Net
public async Task LogChanges<TEntity>(TEntity entity, bool isCreation = false, string fName = "", string lName = "")
where TEntity : class
{
var originalValues = ...
0
votes
1
answer
79
views
500 Error: Internal Server Error with aPI deployed on Azure with swaggwer
I deployed my API on Azure but I get a 500 error with no message! How could I solve this issue? This is my Program.cs:
var builder = WebApplication.CreateBuilder(args);
// Add services to the ...
0
votes
1
answer
26
views
How to handle multiple services with different timeouts/policies in dotnet
HttpClient documentation states that a single HttpClient should be reused throughout the application lifetime to avoid resource exhaustion, but in newer dotnet versions, HttpClientFactory is a way to ...
0
votes
0
answers
35
views
How to pass inherited attribute to custom validator
I am trying to pass an inherited attribute into the IsValid() error message in a custom attribute validator. However, I can't seem to figure out how to do so after searching online for this.
I have a ...
0
votes
1
answer
64
views
My ModelState.IsValid return false on .Net7
I am trying register a new user basically. But ModelState.IsValid return false. I can't solve this problem. I am using Identity in this project.
Here is my UserRegisterController:
using Microsoft....
1
vote
1
answer
147
views
.net5 => Could not load file or assembly System.Runtime, Version=6.0.0.0
I have a solution with several WebAPI projects. All projects worked as needed, nothing changed in code. But one Monday (yesterday) I turned on my computer and tried to debug one of the project, which ...
0
votes
0
answers
40
views
There was an error running the selectd code generator: "There was an error creating a DbContext"
I am trying to build an API with Visual Studio Community using the ASP .NET CORE Web Api project template. Crating the scaffolding of the model created:
public class Game
{
public int Id { get; ...
0
votes
1
answer
22
views
Why can't I see my image in my Image container from .NET solution?
I have an images folder in which I have stored an image. I can see it in my file explorer, but in my .NET solution, I can only see the images folder. I can't see the image which is inside that folder.
...
1
vote
0
answers
66
views
How to add Users in Identity entity called AspNetUserRoles table?
Hi Folks I have a brainfart moment, I have been struggling for this for last week, and I think this is the time to ask for your opinion. So what I am trying to achieve here is to insert the record in ...
1
vote
1
answer
78
views
Endpoint on local API not working unless consumed endpoint is accessed first
I am creating a prototype for a news aggregator web application, right now I am creating the backend for it where it processes endpoints from https://newsapi.org/
In Swagger UI I get this error that I'...
0
votes
0
answers
55
views
How to support multiple external identity providers with an API-only OpenIddict based authorization server?
I'm trying to implement an authorization server based on OpenIddict which doesn't manage any users locally and delegates authentication to a set of supported external identity providers.
My scenario:
...
0
votes
0
answers
20
views
How to Fetch the names of the files that has been generated inside the migration folder? I just want the list of files inside migration folder
I want to fetch the list of files that has been generated inside the migration folder so I tried using getassembly() method but did'nt work how to fetch it? are there any ways?
I tried it using the ...
0
votes
0
answers
112
views
wrong X509IssuerName, wrong X509SerialNumber error in Zatca XML validation
I'm working KSA Zatca eInvoicing phase 2 integration. I'm using SDKNETFrameWorkLib for sigining Invoice xmls. But when I try with Standard Invoices XML it was validating on https://sandbox.zatca.gov....
0
votes
0
answers
42
views
Deploying .NET 6 Web API with GitHub Action: appsettings.json Not Updating with Environment Settings
I am facing an issue with my GitHub Actions workflow where the appsettings.json file is not updating correctly on an Azure Web App. Despite a successful deployment, the appsettings.json file doesn't ...
0
votes
1
answer
39
views
Entity Framework Core POST error (JSON value could not be converted)
I have the following entities:
public class Order
{
public int Id { get; set; }
public string Name { get; set; }
public OrderGroup OrderGroup { get; set; }
}
public class OrderGroup
{
...