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.

Filter by
Sorted by
Tagged with
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 ...
grandeale83's user avatar
-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 ...
Fatih Demirbaş's user avatar
-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 ...
Recep Şamil's user avatar
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,...
jason's user avatar
  • 3,523
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 ...
lovzzzz's user avatar
  • 11
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)) { ...
BennoDual's user avatar
  • 5,929
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 ...
Ruan Faustino Camello Da Silva's user avatar
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 ...
Oliver Weichhold's user avatar
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 ...
adam0101's user avatar
  • 29.5k
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 ...
Cenk's user avatar
  • 187
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 ...
Nice Kloe's user avatar
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 ...
Himanshu Sharma's user avatar
-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....
shanji97's user avatar
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 ...
LeotrimR's user avatar
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 ...
Amir's user avatar
  • 41
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....
KHP's user avatar
  • 3
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. ...
Waz's user avatar
  • 7
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 ...
Som's user avatar
  • 598
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; ...
Waz's user avatar
  • 7
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] [...
EvilDr's user avatar
  • 9,089
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}/...
awj's user avatar
  • 7,568
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("...
Thanh Sơn's user avatar
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 ...
Peter Rundqvist's user avatar
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. ...
Baba's user avatar
  • 2,089
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 ...
Myosotis's user avatar
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 ...
Joe Defill's user avatar
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 ...
fanticuell's user avatar
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 ...
JHJ's user avatar
  • 313
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 ...
cooper_milton's user avatar
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....
SpaceCowBoy's user avatar
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/...
GranmaSquid3's user avatar
-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 ...
Pavan Gopal's user avatar
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 ...
fingers10's user avatar
  • 7,073
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....
slacker's user avatar
  • 147
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, ...
Mohini Mhetre's user avatar
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 = ...
Goktug Baris's user avatar
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 ...
mathdx's user avatar
  • 57
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 ...
stan's user avatar
  • 37
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 ...
MarkCo's user avatar
  • 892
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....
Fatih Demirbaş's user avatar
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 ...
Dimitry's user avatar
  • 257
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; ...
Rafael Gómez's user avatar
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. ...
Ashley Ferns's user avatar
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 ...
shubham maini's user avatar
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'...
Rami Raghfan's user avatar
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: ...
Jonny Dee's user avatar
  • 847
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 ...
Jayanth Prakash's user avatar
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....
Senthamil Selvan.V's user avatar
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 ...
Rakesh Kumar's user avatar
  • 2,833
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 { ...
Waz's user avatar
  • 7

1
2 3 4 5
757