Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

3
votes
0answers
36 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
62 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
48 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
154 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
29 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
57 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
427 views

WebAPI global exception handler

There is a global exception handler in our WebAPI application that looks like the following: ...
3
votes
1answer
55 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 ...
2
votes
2answers
102 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
23 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
58 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
4k 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
342 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
1k 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 ...
1
vote
1answer
125 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
1k 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
202 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
59 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
3k 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
86 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
811 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
81 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
983 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
100 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 ...
5
votes
2answers
14k 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. ...
4
votes
1answer
1k views

Connect to MySQL and fetch a list of customers asynchronously using C#

I am connecting with a database and returning values from a Web API controller. For better performance, I am doing it completely asynchronously with a new task. Am I doing it the correct way? Am I ...
3
votes
2answers
3k views

Simplify IActionResult return value logic

It would be nice to simplify the verbosity of this: ...
2
votes
0answers
71 views

REST API design to handle status migrations

I have a requirement to provide an API which would allow to change status of Order. The API is supposed to follow REST principles, so I have designed an endpoint ...
-1
votes
1answer
3k views

Error handling in a REST API

I have implemented a small REST API using WebApi 2 and NHibernate for ORM. When non-existent id is supplied, NHibernate will throw an InvalidOperationException. So ...
2
votes
3answers
6k views

Web API for reading file system

I will have this code reviewed by back-end devs tomorrow as part of an interview process tomorrow and would like comments on how to improve A) structure B) performance. For structure, it's too late ...
1
vote
0answers
7k views

Download file uisng ASP.Net WebApi

I am using following code to download a csv file using Web API. Maximum file size will be less than 500mb. How can I improve this code? ...
3
votes
1answer
231 views

Stocks application using Web Api

I was given task to build a client server application, using any technology I want. The task was to build a database(doesn't have to be a real database, it can be mocked). the client side should ...
1
vote
0answers
109 views

Designing better api controller

Overview I am designing one api that will be integration with another system, however I stumbled upon one code which I know it can be improved but I don't know how to do it properly. Code ...
3
votes
2answers
150 views

REST API for user access using ASP.NET Core

I have been coding in java for more than 3 years. Recently we had to develop REST Web Services for our customers in ASP.NET Core. I am a newbie to both C# and ASP.NET Core stack. The expectation ...
2
votes
0answers
482 views

ASP.NET web API handling dynamic connection string

I have a project where it is an absolute requirement that each client is on a separate database. My design is to use a class that builds the connection string from the ...
5
votes
1answer
571 views

N-Layered REST API

I am writing a pretty simple REST service in ASP.NET WebAPI with Entity Framework and I decided to use it as an opportunity to learn N-layered enterprise application architecture with some unit/...
1
vote
0answers
130 views

Generating Resource URLs in Multi-Layered Web API 2 Project

I am building a RESTful Api service in .NET. I have a requirement where I need to include resource URLs as part of JSON data returned from the endpoints of my API. The solution currently has the ...
1
vote
0answers
365 views

WebAPI async task pattern, with IDbContextScopeFactory and automapper

I normally abstract data access code into another layer, but I'm currently prototyping and it's not necessary. Does anyone see any issues with this as a general data query pattern, considering the ...
4
votes
1answer
2k views

Dynamically initializing Context and creating connection string for Web API

Scenario: There is a 20 years old windows application with SQL Server as database. There are 42 companies within the Group and each company has its own database. Now we have started building new ...
5
votes
0answers
2k views

How to stream data directly from the database through a 3 tier architecture

The problem: generating a CSV file that is too large be stored in memory in a 3 tier architecture, without the complexity of saving the file to storage. The solution: I've managed to write something ...
7
votes
1answer
2k views

Basic Authentication Token Message Handler

Ordinarily I'm fairly confident in my own code, but seeing as how this pertains to security and I don't want to have overlooked anything that might cause security problems, I figured I should have ...
3
votes
1answer
829 views

Is my n-tier architecture of this web API correct?

I'm making a web API using web API 2. I have three layers: Business - Stores models and service classes. Data - Just EF. Currently one DB. But will include 3 when complete. Web API - Presentation ...
2
votes
0answers
96 views

Fetch object from database, or fetch it using an API if it isn't there

To give some background on this particular code, there is a controller which recieves an object, hashes parts of it and looks into a database to see if there is a similar hash in the db, if there is, ...
1
vote
1answer
2k views

Web API Custom Error Logging

The goal of our application was to use the same custom logging we created for our ASP.NET MVC applications. We implemented a solution that used some of the techniques in ElmahExceptionLogger: ...
2
votes
2answers
2k views

Pass Through Web API calls

Our application architecture consists of: SPA JavaScript calls a set of Web API endpoints The Controllers then call an Entity specific Service Entity specific Service calls a Pass Through Service ...
3
votes
1answer
2k views

HttpClient Wrapper supports ignoring invalid/self-signed certs

I'm using the following as a wrapper for the HtptClient because it doesn't implement an interface -- which makes mocking more difficult. This logic also supports invalid and self-signed certs. ...
3
votes
3answers
294 views

Claiming coupons [closed]

I am currently creating a system that allows a user to claim a coupon, after the coupon is claimed the receive currency on their account. I recently ran into an issue in which if 2 requests with the ...