Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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 ideal choice for building RESTful services.

Filter by
Sorted by
Tagged with
2 votes
2 answers
71 views

ASP.NET Web API for currency

On the basis of the daily exchange rate data of the CB (https://ww.cbr-xml-daily.ru/daily_json.js) it is necessary to create a Web-service using ASP.Net Core, which implements 2 API methods: ...
user avatar
1 vote
1 answer
107 views

Having both bearer token and basic authentications

In my asp.net web API, I have a couple of controllers. In one of my controllers, I am using basic authentication and in another one, I am using bearer token authentication. It is working as it is ...
user avatar
  • 51
0 votes
0 answers
63 views

ISO Xml Serializer for .Net API Controller

I've created a pretty simple XML input formatter, that inherits from XmlSerializerInputFormatter, that is able to serialize XML input that is ISO-8859-1 encoded. I created it, so that I do not have to ...
user avatar
0 votes
1 answer
56 views

ASP.NET Web API 2 reading values from config file or database or elsewhere

In my asp.net web API 2, I am reading values from web.config from the controller into my DTO as a response to the client. It is working as expected, I wonder if there are any improvements to make it ...
user avatar
  • 51
0 votes
0 answers
93 views

Improving the Speed of loading records into a ngx-datatable

I am using ngx-datatable to load large volumes of records. However, the larger the volume, the longer it takes. I read somewhere that you can speed it up by sorting then assigning it to the data ...
user avatar
  • 1
0 votes
1 answer
260 views

Web Api to upload excel file

I work on asp.net core 2.2 web API using C# language I need to rewrite function below with best syntax and with best practice web API below get Excel file from upload and return Excel file it working ...
user avatar
0 votes
0 answers
798 views

Dapper UOW with Multiple Databases

Scenarios / Requirements: I am working on to convert the existing WebAPI Data Layer to Dapper from EF. The following are the ...
user avatar
  • 121
2 votes
2 answers
88 views

Dapper with shops and payers

I live in the buildings that have 50 people in it and for each floor splits into 2 groups each group is from ~9 people. I'm trying to build an Xamarin app (IOS, ANDROID ,Win10,maybe web app) to make ...
user avatar
3 votes
1 answer
66 views

Calling multiple clients from API controller methods?

Hi I have a requirement where in I have to call two different client methods from same api in .NET Core and I have structured my code as follows. THis is working fine but Please give me your ...
user avatar
0 votes
1 answer
1k views

Generic Wrapper class for HTTPClient methods

I am trying to using HttpClient for making API calls from a different domain and for that purpose I have created the following service class after doing some research. It is 4.7.2 framework and not a ....
user avatar
2 votes
0 answers
206 views

How to make a good session handling with NHibernate?

here I leave my code for a repository pattern with NHibernate and Autofac. I would like to receive some feedback about it. Especially about the session handling with NHibernate. By now I don't like ...
user avatar
-1 votes
1 answer
403 views

Making a generic web API controller when using multiple tables with similar fields

I have been trying to refactor my code since I found I've been doing a lot of copying and pasting to implement the logic of the web API controllers. Here's how the controllers looked like before ...
user avatar
2 votes
0 answers
321 views

How to use single child Unity container for OWIN middleware and WebAPI

I am using OWIN to self host a WebAPI service. There is Unity to serve as an IoC container. Within several OWIN middlewares (e.g. authorization layer) as well as in WebAPI I need to access a Unity ...
user avatar
5 votes
1 answer
324 views

Parallel Calls to External WCF Service - ASP.NET Web Api

I have come across a situation where I feel running some code in parallel will greatly improve performance, but I am concerned about the implementation and am looking for some confirmation. Take the ...
user avatar
  • 51
1 vote
0 answers
2k views

.NET Core Dependency Injection - Worker Service x Web Api [closed]

Folks, I have a big question about how .NET dependency injection "native/default" works on a Service Worker scope. We need to resolve a service(...
user avatar
  • 202
7 votes
3 answers
2k views

C# Am I using proper SOLID principles?

I am currently practising using the SOLID principles in C#/.NET I have made a little example, but i am not sure if i have followed it correct. Its a simple example where i have an API controller that ...
user avatar
  • 130
2 votes
1 answer
161 views

ASP.NET Web API Authentication For Xamarin App

I've recently been learned how to implement a token based authentication with ASP.NET and I would love to get some input on how my code & structure is as well as how I can make it better. The code ...
user avatar
2 votes
0 answers
40 views

API Layer ClientId and Security style

Im at the point where I am designing my api security and I was going with a custom attribute I don't want to use third party systems as they cost money. I was going to use the client id and the ...
user avatar
1 vote
0 answers
42 views

Concurrent requests are not permitted in specific time period

In my web API, the client wants me to implement logic in order to control/block concurrent requests in a specific time period. I added RequestInterval which is 10 seconds in the appsettings of web ...
user avatar
2 votes
1 answer
250 views

Handling external API calls status code in my application

I have a Web API application in .NET Core 3.1. In a controller I have a GET action that must return a JSON object with a name and a description. In order to retrieve the correct description I need to ...
user avatar
  • 23
2 votes
0 answers
384 views

Web API get data with many optional parameter in .NET Core

I would like to do a refactoring of web API implemented in .NET Core. The Goal is to simplify ...
user avatar
3 votes
2 answers
155 views

Asynchronous catalog with paging and partial views

I'm trying out .net core with mvc in a personal project, the latest functionality I've added was a project catalog, primarily ajax based, it's displaying a list of projects fetched from the database ...
user avatar
  • 8,418
2 votes
0 answers
80 views

Retry HttpClient request without handlers

I have a server and client application. In the client application, there are HttpRequestException class exceptions on requests. As it seems to me - these exceptions happen in isolated cases and not ...
user avatar
1 vote
1 answer
814 views

Filtering items in an ecommerce site with asp.net mvc and ajax

I'm trying to filter items from an ecommerce site.The project on the local server was running smoothly.However, I noticed significant delays since the project was published on the global server.Most ...
user avatar
  • 53
2 votes
1 answer
64 views

Active Directory security groups Search application optimization

I have a Web API method that returns the Active Directory security groups for the specific login user. The below code was working fine but it was taking so munch time nearly 45 sec to get the results....
user avatar
  • 121
2 votes
0 answers
422 views

Stream JSON from Azure Cosmos DB to browser in Web API

I have an HTTP endpoint for returning data directly from Azure Cosmos DB. The endpoint is basically a database access point (this seems like a common case). Since I'm returning the data unmodified, ...
user avatar
  • 133
4 votes
2 answers
952 views

Calling rest API with HTTPWebRequest

I am calling a rest API as follows. I wonder if there are ways to improve/optimize the code. Should I add time-out or cancellation token? Any help would be appreciated. ...
user avatar
1 vote
0 answers
55 views

Subscribe once and reuse the Angular Subscription each second

I am creating a web application using Angular 8. This application is all about talking to the stock markets server and getting the Live updates every second. I have one query here. Below is my code: <...
user avatar
  • 11
2 votes
1 answer
604 views

Asp.net web API Nlog implementation with UnhandledExceptionHandler

I have an asp.net web api. I would like to log errors into a file. So I decided to use NLog. I already have UnhandledExceptionHandler so I added NLog as follows. I removed all the try/catch in order ...
user avatar
6 votes
1 answer
160 views

Custom HttpClient implementation for third part usage with sync/async calls

I'm doing an implementation of HttpClient that is built in a NET Standard project, which will be used as a base to build and process JSON requests/responses for a third part REST API. Client is built ...
user avatar
2 votes
1 answer
79 views

418 I'm a TeapotServer for RESTful integration-tests

I created a test-server for RESTful integration-tests that I call TeapotServer because I like the status-code 418 that the ...
user avatar
  • 43.8k
1 vote
0 answers
70 views

Tightly coupled Basic Authentication Filter

I have an asp.net web api and I would like to use basic authentication. Is there any way to make this loosely coupled? I tried constructor DI but I couldn't figure it out how to pass Dbcontext into ...
user avatar
  • 31
2 votes
1 answer
96 views

Exception, errors handling, best practice in WebApi Core

I'm making my WebApi project. My logic is, the controller didn't see data. It only triggers a service that returns objects to it. My simple method from ...
user avatar
2 votes
0 answers
833 views

Ninject binding for Dbcontext

I have an asp.net web API and I am using EF6 to connect to a third party rest API which sells online game codes. We made a deal with the company so clients have to call my rest API in order to get the ...
user avatar
  • 31
1 vote
1 answer
104 views

Login flow in app

I made the login flow without any reference to a tutorial. So I want some feedback. Basically it sends username and password in a POST request to /token. The app stores the tokens on device, then ...
user avatar
  • 347
1 vote
0 answers
203 views

Converting IActionResult to something that can be mapped in JS

I have the following ReactJS unordered list which is generated from answers: ...
user avatar
  • 11
3 votes
0 answers
2k views

Controller in an ASP.NET Web API application which generates a CSV file

I have a controller in an ASP.NET Web API application which generates a CSV file. The controller looks like this: ...
user avatar
  • 553
1 vote
0 answers
248 views

Design Web API with Command Handler

I'm setting up new API to Setup LocalAccounts and need your advice on how to design the API with CQS some background : LocalAccount Is Account that related to ...
user avatar
  • 11
2 votes
0 answers
138 views

Web API CRUD Demo with Console App and MVC Web Application

I have created a simple CRUD method using Web API project which consumed by 2 platform: Console App and MVC Web Application. The EntityModel project is mainly the entity and the DAL layer. Is my ...
user avatar
0 votes
0 answers
3k views

Using RabbitMQ in asp.net web api

Use case : I have a Order web Api which creates an orders and publish the order to messaging queue. Notification service (web api 2) consumes this message by subscribing to the messaging queue and ...
user avatar
  • 113
1 vote
0 answers
139 views

Transparent proxy using HttpClient

I'm looking for feedback on some code I've written to work as a transparent proxy. I'm developing a web app that needs information from another web site's API, but that web site has disabled CORS and ...
user avatar
  • 11
2 votes
0 answers
982 views

Repository + Unit Of Work Pattern in WebAPI

I am refactoring my existing product's webapi part of the solution. Current Repo pattern does not allow me to add custom functions to a specific repository. In result, most of the functions directly ...
user avatar
  • 121
2 votes
1 answer
1k views

WebAPI global exception handler

There is a global exception handler in our WebAPI application that looks like the following: ...
user avatar
3 votes
1 answer
67 views

Create objects corresponding to whichever field has value from among a list of fields

I have to create a form, which enables users to move stock of items to different statuses. The form will show the current stock(quantity) in a given status and then 5 input fields corresponding to 5 ...
user avatar
  • 133
1 vote
2 answers
429 views

Design Pattern to Add, Edit and Delete Records

This code allows Add, Edit and Delete a database record for the Category table. Separate Service classes are implemented to handle these operations which are called ...
user avatar
3 votes
2 answers
117 views

Subscribe to Event form one service to another

In my architecture I have service layer, and for my question two relevant classes in this layer: UserManagementService EmailSenderService In first service there is method: ...
user avatar
  • 231
2 votes
0 answers
37 views

Looping JSON to get matching values from Database

I have a need to take in a payload that looks like this: ...
user avatar
0 votes
0 answers
75 views

Inject settings as a dependency, and serve them using a Web API

I used an opportunity to learn about Dependency Injection and DDD, therefore, althought any feedback is welcome, I am interested in feedback about those software design principles. I have a small ...
user avatar
  • 361
6 votes
3 answers
16k views

ASP.NET REST controller with try-catch error handling

Yesterday someone guided me through this article and I'm wondering whether I should use try-catch implementation or not? I have the following code below which is actually a RESTful service and I have ...
user avatar
2 votes
0 answers
612 views

Change the identity from Azure AD to identity of application and return new token

I use this code to change the identity coming from Azure AD in an identity usable by my application, then i generate a token for this identity and return it in the response headers. Is this secure? ...
user avatar
  • 121