Category "asp.net-web-api"

How to set HttpResponse to HttpResponseMessage in Web API

I have a asp.net web API application hosted using OWIN. The web API application uses an external library which depends on System.Web and writes its response on

Changing the parameter name Web Api model binding

I'm using Web API model binding to parse query parameters from a URL. For example, here is a model class: public class QueryParameters { [Required] pub

asp.net web api: action filter attribute is thread-safe by default?

Can some one confirm me that asp.net web api action filters are singleton/instance based by default? In asp.net core, I observed that it has one instance by def

ASP.NET Web API and OpenID Connect: how to get Access Token from Authorization Code

I try to get OpenID Connect running... A user of my Web API managed to get an Authorization Code of a OpenID Connect Provider. How am I supposed to pass this co

Passing UTC DateTime to Web API HttpGet Method results in local time

I'm trying to pass a UTC date as a query string parameter to a Web API method. The URL looks like /api/order?endDate=2014-04-01T00:00:00Z&zoneId=4 The s

How do I remove an existing claim from a ClaimsPrincipal?

I am making a developer tool for impersonating Roles for an intranet site to allow developers to quickly act as any Role as needed. Roles defined are Developer

Azure AD API request 401 Unauthorized

I have a standard Web API running on an Azure website with Azure AD authentication enabled, when browsing to the API in a browser I am able to login via the bro

Order of execution with multiple filters in web api

I am using latest web api. I do annotate some controllers with 3 different filter attributes. 1 [Authorize] 2 [RessourceOwnerAttribute derived from Authorizat

How do I get ASPNET WebAPI working with Microsoft.Owin.Host.HttpListener on an Azure worker role using an IoC container?

When I have the following packages installed in an Azure worker role: <package id="Microsoft.AspNet.WebApi.Client" version="5.1.0" targetFramework="net451"

Swagger UI Web Api documentation Present enums as strings?

Is there a way to display all enums as their string value in swagger instead of their int value? I want to be able to submit POST actions and put enums accord

notification does not implement $INotification C#

I have a multi-tenancy project using mediator and CQRS, for some reason my CRUD from order request are returning this error, I already try refactor my handler s

How to test database methods and get code coverage xUnit ASP.NET

I initially used the Moq library for testing, since I don't actually want to mess the data in my database. However, I quickly realized instead of running the co

Request.Content.IsMimeMultipartContent() fails

I'm trying to upload a file using the Html2 input type="file" and an angular2 http.post request. When the request reaches the web api, it fails in the Request

How can I catch an exception and send it as json message?

I wrote a code but for some reason it doesn't work...can you tell me what's wrong? I want the app not to stop when I get an exception, only to send that excepti

Enabling authentication in swagger

I created a asp.net core empty project running on .net6. I am coming across an issue when I am trying to enable authentication in swagger. Swagger UI runs as ex

System.Net.WebException: Error: NameResolutionFailure when Calling WEBAPI in xamarin forms

I have created one simple xamarin form application using PCL, which is showing data in listview using WEBAPI. When i call WebAPI , i am getting below error. ex

Testing web API service

I'd like to test the methods of a given Web API service. I could do this by adding a test project, instantiating the controllers and testing the methods. Howeve

How to return a file using Web API?

I am using ASP.NET Web API. I want to download a PDF with C# from the API (that the API generates). Can I just have the API return a byte[]? and for the C# ap

ASP.NET Core: Error while Updating Migration (Database first approach)

I have created an application in .NET Core where I am trying with database first approach. I was able to add Migration using "Add-Migration InitialCreate" but

Make sure that the controller has a parameterless public constructor error

I have followed this tutorial which has worked great, until I modified my DbContext to have an additional constructor. I am now having issues with the resolutio