ASP.NET Web API2 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.

learn more… | top users | synonyms

0
votes
0answers
11 views

Remove Cookie from WebApi to Web Service Request

I have a WebApi (v2) which calls another web service. The other web service (which is out of my control) sends a Set-Cookie header in the login response. Of course, after this, every time I make a ...
0
votes
1answer
28 views

Resolving interfaces in WebAPI

I have a controller method with the following signature [HttpGet] [Route("results")] public List<IResult> GetResults() { return repo.GetResults(); } Not surprisingly, I get a JSON .NET ...
0
votes
1answer
18 views

Where is the Autofac InstancePerApiRequest scope disposed?

I am going through the code of both Autofac.Integration.WebApi and Autofac.Integration.WebApi.Owin and I can see how the InstancePerApiRequest/InstancePerHttpRequest lifetime scope is being created ...
0
votes
1answer
16 views

Web Api - How to return a dynamic object with 201 status code

I'm trying to return the recently added entity Id in a Web Api action method as a JSON. Example: { bookId = 666 } The Controller Action code is as follows: [HttpPost, Route("")] public ...
1
vote
1answer
35 views

Timeout a Web Api request?

Like MVC WebApi runs on the asynchronous ASP.NET pipeline, meaning execution timeout is unsupported. In MVC I use the [AsyncTimeout] filter, WebApi doesn't have this. So how do I timeout a request in ...
0
votes
1answer
15 views

How to integrate Autofac with WepApi 2 and Owin?

I am using this package to integrate Autofac with my WebApi Owin application: https://www.nuget.org/packages/Autofac.WebApi2.Owin And following this post: ...
0
votes
0answers
15 views

WebAPI with WebSockets

I am trying to implement live updates to my clients, browser compatibility is not a problem for me so I have chosen plain web sockets as opposed to implementing SignalR. I am using WebApi which is ...
0
votes
1answer
8 views

Web API Form - Url Encoded Complex Parameter

Deserializing a complex type in WebAPI is giving me serious grief. The data contains keys that are syntactically invalid in c# as property names. How can I translate the key names? Relevant: Web API ...
0
votes
0answers
13 views

Load web api controller dynamically

I run web api with owin hosting. In my OwinHost project I do this: public class CustomResolver : DefaultAssembliesResolver { public override ICollection<Assembly> GetAssemblies() ...
0
votes
2answers
30 views

WebAPI not serializing inherited class on POST?

Here is my controller method: [System.Web.Http.HttpPost] [System.Web.Http.Route("api/exercise")] public HttpResponseMessage CreateExercise(ExerciseDto exercise) { Here are my classes: ...
0
votes
1answer
12 views

How to send post request through Angular to ASP.net web API

I am new to both angular and ASP.NET web API. in angular i get values from a form and try to pass it to the server through post request her is the code for angular. ...
1
vote
0answers
34 views

Value object serialization options

I am coding a value object for my domain object identifier, similar to what is done here. Basically I am just wrapping a guid. By following this article's advice I was able to create a custom model ...
0
votes
0answers
7 views

kendo Grid update and insert with jayData and angular

i tried to use kendo grid by crud Operation that cooperate with Jaydata and angularjs to create DataSource and implement crud Operation.but when i update or create a record after submit on server i ...
0
votes
0answers
19 views

Facebook Authentication in MVC Web API Without Local Authentication

I have an application that I would like to be heavily integrated with Facebook. At the end of my project I would like to have a Facebook Canvas App, iOS App, and Android App. All will use Facebook ...
0
votes
1answer
20 views

“error”: “invalid_client” from custom OWIN implementation

I am implementing OWIN authentication on a mysql backend, I dont thnk thats a problem as my registration work pretty well. I have basically worked off this post (i.e. nicked most of the code). I am ...
1
vote
1answer
30 views

What would cause attribute routing to not work when adding it to an existing MVC 5 web app?

I added the Web API nuget and the StartUp WebApiConfig code that calls MapHttpAttributeRoutes via Global.asax, but none of the attribute routes are working. protected void Application_Start() { ...
0
votes
0answers
15 views

Azure Mobile Services - Does it ignore Application_Start?

In an Azure Mobile Service project, I have a static class WebApiConfig with a static method Register() located in the App_Start folder. From Global.asax.cs, I used to call the register method: public ...
0
votes
1answer
16 views

Is it possible in ASP.Net Web API 2 to have different OWIN UserManager for root and a area?

We currently have OWIN setup to authenticate our Web APIs that are at the root site. These are used by normal users. We are now in need of the ability to call similar functionality, but as a admin. We ...
0
votes
1answer
24 views

IHttpActionResult variable passing null in test method

I am writing a test method for an IHttpActionresult controller. The ActionResult is not NULL and contains the required data (Customer.ID = 986574123). However in line two the variable CreatedResult is ...
0
votes
0answers
34 views

ASP MVC 5 Web Api 2 pass e-mail through

I followed this tutorial to get my live account oauth working on my asp mvc 5 and web api 2 app. All goes well and with an additional scope I can fetch the users e-mail. But how do I pass it through ...
1
vote
1answer
24 views

OWIN Web api 2 adding additional logic to Bearer authorization

I am attempting to implement OWIN bearer token authorization, and based on this article: http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/, I get the ...
0
votes
0answers
23 views

WebAPI 2 Authorize attribute failing every time on EF controller

I'm about at my wit's end with authorization in WebAPI (at work, we have a simpler scheme). I created a project using the Single Page Application template using Entity Framework. My database is an ...
0
votes
0answers
21 views

use asp.net web api token to authenticate my asp.net mvc application

I have created a new web api project with individual user account authentication. I followed this post and everything worked as expected ...
-1
votes
0answers
26 views

Web API 2 Authentication without aspnet identity

I am currently developing a web service with Web Api 2 that is called from other web sites we have developed. We have a few web apis that talk to eachother to get information and are currently using ...
0
votes
0answers
23 views

Add custom key on C# Aspnet WebApi result object

I have to create Asp.Net WebApi. I have this structured objects [Serializable()] public partial class OrderList { [Key] public string ClienteId; public List<Ordine> Ordini; } ...
0
votes
0answers
21 views

WebAPI Custom ControllerBuilder Not Being Called

I've got a custom controller buildre defined in my WebAPI solution and I've just updated to the latest version of MVC and it appears that this controller builder is no longer being called thus all my ...
1
vote
2answers
50 views

Web API 2 returning text/plain responses

Really struggling with something I hope people here can help with. I'm writing a RESTful API in Web API 2. Whenever I send a request to this service, the response is consistently being sent with a ...
0
votes
1answer
44 views

Weird “Object reference not set to an instance of an object” error while using Moq

I am trying to run my test however the I get an "Object reference not set to an instance of an object". Any thoughts? I am using Moq. Test Method: // Arrange ...
1
vote
2answers
37 views

Null parameter with MVC Web-API in OWIN Self-Host

I'm hosting the Web-API using OWIN on a Azure Worker Role following this tutorials: http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api ...
0
votes
2answers
35 views

Preventing Cross-Site Request Forgery Attacks With a Windows Client Application

I develop an web application by web api2. My client application is a windows application that developed by C# , .net 4.0. The client application sends some Json data to the web api application and ...
0
votes
3answers
22 views

Setting content-type for Web API 2 response

I'm really confused about the most appropriate way to return responses for my RESTful API that I'm building using Web API 2. At first I made my actions return IHttpActionResult and in the method I ...
1
vote
1answer
41 views

How to return from an IHttpActionResult method a custom variable?

I am trying to get this JSON response with an Ihttpstatus header that states code 201 and keep IHttpActionResult as my method return type. JSON I want returned: {"CustomerID": 324} My method: ...
0
votes
0answers
13 views

Project structuring and layering of a WEB API solution

We are in discussion mode for deriving the solution/project structure for our Web API solution. This addresses the Domain modeling, Infrastructure, Data Access, Logging, Tests Project ...all of it ...
0
votes
1answer
26 views

DateTime Format In Model Binding

In my Web API project I have following model: public class ModelClass { [Required(ErrorMessage = "Date Cannot Be Empty", AllowEmptyStrings = false)] [DataType(DataType.Date, ...
1
vote
1answer
49 views

Render dictionary with foreach

I've got a dictionary that has been serialized by WebApi2 so that the key is the object name and the value is the value. How can I make knockout render that with it's foreach binding? I tried to ...
1
vote
0answers
39 views

Best practice to return different data in Web Api 2 with HTTP Accept Header

We have a Web Api 2 project with the following route: public class AccountController : ApiController { // GET /accounts/search?name={name}` public PagedSearchResult<SimpleAccount> ...
0
votes
0answers
14 views

ReadAsStreamAsync stuck in Waiting For Activation

I'm getting a Task<HttpResponseMessage> result from the server and I'm trying to read a stream from it in the following way: result.Result.Content.ReadAsStreamAsync().ContinueWith((task) => ...
2
votes
0answers
41 views

ASP.NET MVC 5 WEB API with individual user account authentication

I'm new to the ASP.NET MVC 5 and WebAPI 2 technology. I am currently developing a web service for my desktop application. I have developed the web service with individual user account authentication ...
0
votes
0answers
10 views

Post to a parameterless REST service using WebApi

I have a restful api that I need to call. The method I need to call does not expect any input. However I am not able to use the webapi client to post without parameters. I have the following code: ...
1
vote
2answers
16 views

Redirect to error controller in web Api

I write project WEB API 2 and I'd like to show json result in my custom format when I user wrong url like "localhost/api/v1/" or "localhost/api", for this I tryed to create ErrorController with get ...
0
votes
0answers
24 views

HttpResponseMessage content is not getting serialized for BadRequest responses

I have ASP.NET application, with some MVC and WebAPI controllers in there. MVC 5.1 and WebAPI 2.1. There is no tricky configuration at all, the only thing is getting configured is removed XML ...
1
vote
1answer
45 views

Parent object goes out of scope when I have captured child property - when does it dispose the child property?

I wasn't quite sure how to word the question, but to elaborate, I'm using the AWS SDK in my ASP.Net Web API 2 project and I want to return a response stream for an S3 object - the stream is delivered ...
0
votes
1answer
47 views

log4net on WebApi 2.1 using ExceptionLogger

How does one properly implement WebApi 2.1's ExceptionLogger so that log4net logs the correct values for method, location and line? What I'm trying to achieve is a global exception logger to log ...
1
vote
1answer
22 views

Is OWIN/Self-Hosting required for Web API v2 authorization/authentication

I have been trying to learn how to implement authentication and authorization within an ASP.NET Web API v2 project. Does the Web API need to be self-hosted via OWIN before authorization can be ...
0
votes
1answer
30 views

Catching exceptions in web api - Should I use a try-catch statement?

This is a sample ApiController used [RequestExceptionFilter] public class RequestController : ApiController { public IHttpActionResult Post([FromBody]Request RequestDTO) { //some ...
1
vote
1answer
30 views

UrlHelper.Link() returns null

I know that there are a number of questions here that have this title, but, having been through them, I do not believe any of the posted solutions help. I have the following code in a Web Api v2.1 ...
0
votes
2answers
38 views

500 Server Error when calling RESTFUL Web API over HTTP

I have the following structure for my WEB API controller: public class MyController : ApiController { [System.Web.Http.HttpPost] public bool Method1([FromBody] int id, [FromBody] string token, ...
0
votes
0answers
7 views

Web API 2 Patch using OData - how to best handle case sensitivity?

I am PATCHing JSON from the client to my Web API 2 controller. The request looks like: Request URL: http://localhost:28029/PlaylistItem/5df2b99f-e021-4c81-8ff5-a34c013470aa Request Payload: { ...
0
votes
1answer
35 views

WebAPI CORS - why is the OPTIONS request making its way into my Controller?

I have CORS working with the following: [System.Web.Http.HttpPut] [System.Web.Http.AcceptVerbs("OPTIONS")] [System.Web.Http.Route("api/exercise")] public HttpResponseMessage ...
0
votes
2answers
93 views

Migrating to the WebApi 2.2 RC and getting Response Status 406 (not acceptable)

I migrated to the WebAPI 2.2 RC (Microsoft.AspNet.WebApi -Version 5.2.0-rc) and I since them I get only 406 (Not Acceptable) as status response on all my queries, for example: ...