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.

-1
votes
0answers
10 views

System.InvalidOperationException(An exception was thrown while attempting to evaluate a LINQ query parameter expression) [on hold]

I don't know what's wrong with my LINQ query, everything looks fine but I got above error on the following code: if (!dbcontext.AndroidUser.Any(user => user.Equals(value.UserName))) Here's my complete ...
1
vote
0answers
31 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
25 views

WebApiConfig Register Dbcontext usage [closed]

I am trying to implement basic authentication. I am using asp.net web API and EF code first approach. Here is the class I am trying to query the DB table. ...
0
votes
0answers
27 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
66 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
44 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
122 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
70 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
29 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
94 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
71 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
51 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
439 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
33 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
69 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
554 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 ...
1
vote
2answers
148 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
106 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
25 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
59 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
5k 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
371 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 ...
1
vote
1answer
126 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
2k 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
260 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
61 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
4k 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
87 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
900 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
82 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
106 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 ...
6
votes
2answers
16k 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
2k 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
4k 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
7k 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
8k 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
252 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
111 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
156 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
502 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
657 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
132 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 ...