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

ASP.NET Web API is a framework that makes it easy to build that reach a broad range of clients. These Web-APIs can be consumed by any clients capable of communicating via HTTP (including browsers, mobile clients, desktop applications, and other web applications). It is useful for building ful applications on the Framework.

Web API was created by Microsoft and released on 15th August 2012.

Web API can be hosted:

  • within
  • outside of ASP.NET and IIS - also known as "self-hosted" (i.e. directly inside a Windows service, WPF application or console application)
  • in memory (not accessible via HTTP from outside of the process, but useful for end-to-end testing scenarios or mocking).

As Microsoft had multiple approaches within its technology stack for creating REST services; WCF Web API, ASP.NET MVC controllers returning JsonValue results; this represents a rationalisation and merging of these efforts. The ASP.NET Web API stands separately from WCF and does not deprecate (at this point) the WCF Web HTTP programming model.

Related tags

37671 questions
12
votes
1 answer

ASPNetCore API Content negotiation not working

I'm trying to get my api set up so it will respond with with XML or JSON depending upon the Accept header. I'm following the tutorial by Shawn W: https://wildermuth.com/2016/03/16/Content_Negotiation_in_ASP_NET_Core It says to add a package to:…
12
votes
2 answers

best practice for using async await in webapi

I have .NET core Web API which as service layer. Service layer has all EF code. If have basecontroller with this code protected Task NewTask(Func callback) { return Task.Factory.StartNew(() => { try …
krishnakumar
  • 617
  • 1
  • 6
  • 22
12
votes
2 answers

Creating a variable zip archive on the fly, estimating file size for content-length

I'm maintaining a site where users can place pictures and other files in a kind of shopping cart. After selecting all the various contents the user wishes to download, he can checkout. Till' now an archive was generated beforehand and the user got…
yan.kun
  • 6,820
  • 2
  • 29
  • 38
12
votes
0 answers

Live-Streaming webcam webm stream (using getUserMedia) by recording chunks with MediaRecorder over WEB API with WebSockets and MediaSource

I'm trying to broadcast a webcam's video to other clients in real-time, but I encounter some problems when viewer's start watching in the middle. For this purpose, I get the webcam's stream using getUserMedia (and all its siblings). Then, on a…
12
votes
2 answers

Protecting Web API 2.2 with IdentityServer4

I have Web API 2.2 which uses .Net 4.5.2 framework which is being used by angular2 application and there is existing IdentityServer4 implementation. I want to protect my Web API using IdentityServer4. My question is can I protect Web API 2.2 using…
Pankaj Kapare
  • 7,486
  • 5
  • 40
  • 56
12
votes
1 answer

Multiple controllers with same URL routes but different HTTP methods

I've got a following two controllers: [RoutePrefix("/some-resources") class CreationController : ApiController { [HttpPost, Route] public ... CreateResource(CreateData input) { // ... …
12
votes
6 answers

How to read FormData into WebAPI

I have an ASP.NET MVC WebApplication where I am using the ASP.NET Web API framework. Javascript code: var data = new FormData(); data.append("filesToDelete", "Value"); $.ajax({ type: "POST", url:…
ghanshyam.mirani
  • 3,075
  • 11
  • 45
  • 85
12
votes
1 answer

How can I read JSON from a StringContent object in an ApiController?

I'm writing an API controller intended to receive and parse the contents of a JSON asynchronous post, and am unable to read the contents of the StringContent object in that post. Here is the section from my API controller where I expect to see the…
Ken Palmer
  • 2,355
  • 5
  • 37
  • 57
12
votes
6 answers

'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'

I am trying to create a Web API in VS 2015 Pro (Update 3) using C# and targeting .NET Core. I am following this tutorial. However, I am connecting to a MySQL database instead of an SQL Server database - not sure how much difference that…
12
votes
3 answers

Calling another Web API controller directly from inside another Web API controller

Given a controller Proxy and an action of GetInformation. I want to be able to call the method GetInformation of the Users controller. Both the WebAPI controllers are in the same project but direct calls like var controller = new…
VulgarBinary
  • 3,520
  • 4
  • 20
  • 54
12
votes
0 answers

XML model binding fails in ASP.net WebApi2 after a time

I have several webapi micro services hosted in TopShelf containers which accept and reply with JSON and XML formatters. After running for a time, the XML formatter stops binding the XML request data to the model. Passing JSON or Form-Data still…
psaxton
  • 1,693
  • 19
  • 24
12
votes
3 answers

How to secure generated API documentation using swagger swashbuckle

I have implemented API documentation using swagger swashbukle. Now I want to publish generated documentation as a help file in my website. How to secure this link and publish?
Priyanka Mane
  • 517
  • 2
  • 9
  • 23
12
votes
2 answers

How to overload WebApi method

I am new to WebApi and right now i have two httpPost method like this [HttpPost] public List AddPersonDetails(YellowPages.Person person) { Repository.Repository.personsList.Add(person); return…
Lijin Durairaj
  • 4,910
  • 15
  • 52
  • 85
12
votes
1 answer

Highly available Service Fabric WebApi hosted on Azure

We are exposing a stateless Owin WebAPI hosted on all nodes in our service fabric cluster (instance count -1) on Azure. The WebAPI is meant for public consumption and should be highly available even in the face of upgrades to the internal services…
12
votes
3 answers

RestSharp showing Error of Cannot create an instance of an interface have to manually deserialize

I have RestSharp (which is like HttpClient) call and return data from a Web Api method I'm getting this error {"Cannot create an instance of an interface."} My code looks like this: public List GetInterests() { var request = new…
Timothy Fisher
  • 185
  • 1
  • 11