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
0answers
20 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 ...
1
vote
0answers
39 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 ...
2
votes
1answer
46 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 ...
1
vote
0answers
57 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 ...
3
votes
2answers
135 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 ...
2
votes
0answers
39 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 ...
1
vote
1answer
89 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 ...
2
votes
1answer
42 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....
2
votes
0answers
122 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, ...
3
votes
2answers
114 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. ...
1
vote
0answers
32 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: <...
2
votes
1answer
177 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 ...
6
votes
1answer
93 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 ...
2
votes
1answer
53 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 ...
1
vote
0answers
54 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 ...
0
votes
0answers
33 views

Business logic refactoring needed

I am using asp.net web API and EF code first. I am querying the database based on values inside of the request object (initiate). If there are results, I am updating the database. Then I am querying ...
2
votes
1answer
76 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 ...
0
votes
0answers
170 views

JWT generation/validation

In my asp.net web API rest application, I am using JWT generation and validation as follows. Would you please check my sample code? If I make it expire let's say after a day, what might be the costs? ...
2
votes
0answers
311 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 ...
1
vote
1answer
88 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 ...
1
vote
0answers
55 views

Converting IActionResult to something that can be mapped in JS

I have the following ReactJS unordered list which is generated from answers: ...
3
votes
0answers
730 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: ...
1
vote
0answers
120 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 ...
2
votes
0answers
106 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 ...
0
votes
0answers
2k 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 ...
1
vote
0answers
63 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 ...
1
vote
0answers
629 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 ...
2
votes
1answer
963 views

WebAPI global exception handler

There is a global exception handler in our WebAPI application that looks like the following: ...
3
votes
1answer
59 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 ...
1
vote
2answers
172 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 ...
3
votes
2answers
108 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: ...
2
votes
0answers
33 views

Looping JSON to get matching values from Database

I have a need to take in a payload that looks like this: ...
0
votes
0answers
63 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 ...
6
votes
3answers
9k 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 ...
2
votes
0answers
455 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? ...
4
votes
1answer
2k views

Trying to map JSON to different classes in web API [closed]

I have a controller action that takes JSON bodies. I know, that the JSON is either of type A or B, where both classes are of ...
2
votes
1answer
147 views

Using coalescing and conditional operators to check API arguments

I have a web application that allows users to create customs items and later change those items. For eg. a change, the application takes the parameters and performs some basic sanity checks. If the ...
3
votes
1answer
6k views

Giving error response in Web API

I'm creating a Web Api in .NET Framework that is connected to an ASMX service. No own logic, just pass through data. Everything works as expected. But not sure if it's good. Have to repeat the same ...
7
votes
1answer
480 views

Setting up pagination links inside a WebAPI Controller

I'm implementing paging for the first time and have the following code which achieves what I want. There are just a couple of things that feel a bit weird to me and would like if somebody could give ...
2
votes
1answer
76 views

IsDatabaseUp returns true or throws exception

I want to write an ASP.NET Web API endpoint that allows clients to check if database is running. The method below is check if database is up by establishing a connection and running a dummy sql ...
1
vote
1answer
5k views

Reading MultiPart From Data with descriptors

I am new to C# and I have a simple /upload controller to upload an image to S3. Everything seems to work, just fine but it seems messy. The function: Takes multipart form data Reads it async Picks ...
1
vote
0answers
56 views

The Login Authentication Model Class for ApiController

This class accepts input parameters (Login and Password) from ApiController via ...
6
votes
0answers
2k views

Authenticate ASP.NET Web Api 2 using OWIN and Firebase

I'm about to go live with an app, and would, therefore, appreciate a review of my firebase authentication setup. I haven't been able to find many resources describing how to perform such ...
1
vote
0answers
102 views

ChatApp (Web API, Windows Forms and Azure SQL Database)

I have been working on chatApp (my first app in c#). I used Azure SQL Database, ASP.NET Web API and WinFroms. The app works very well with no errors Please give me your professional opinion and ...
2
votes
0answers
947 views

Adding support of HTTP PATCH

I have an API endpoint to modify a race car, which supports the PUT method: PUT /api/racecars/{racecarId} Since PUT must be ...
1
vote
0answers
90 views

Build a template service that will replace any word given with a new word

This is the user story assigned to me in one of the interview. Personally, I think the user story is not well defined for a developer who has no knowledge about business. User Story: One of the ...
1
vote
0answers
1k views

HTTP PATCH method for WebAPI

I'm working on an implementation of the HTTP PATCH method for WebAPI. I know there are packages like JsonPatch and OData Delta for that, but they don’t work for me. JsonPatch is too complicated and ...
0
votes
1answer
121 views

Controller with too many parameters with DI [closed]

Is there a way to reduce the number of parameters of this constructor? All the services must be used in this Controller. The majority of them are used more than 2 times(some of them >10), with the ...
7
votes
2answers
20k views

C# - Entity Framework + Repository pattern + Unit of work pattern

After hours spent on reading various articles about correct way to implement Repository patter & UoW patters I finally think that I have managed to create (hopefully good) implementation. The ...
0
votes
1answer
2k views

Async task post method WebAPI controller

I have a post method in an WebAPI2 controller. I just want to make sure that everything I have done is correct. I want to create a new task run the method asynchronously and return a message. ...