0
votes
2answers
30 views

Serializing complex EF model over JSON

I have done a lot of searching and experimenting and have been unable to find a workable resolution to this problem. Environment/Tools Visual Studio 2013 C# Three tier web application: Database ...
0
votes
0answers
11 views

Jquery getjson calling wrong domain in asp.net web api [duplicate]

I am learning Asp.Net web Api from the book Practical Asp.Net Web Api by Badrinarayan Lakshmiraghavan. Using Visual Studio 2013, I have created an app having two projects TalentManager.Core and ...
0
votes
0answers
12 views

Do I need to replace HttpWebRequest with one that has a “Content” member, or do I need to use a different type altogether?

In Web API server code, I need to respond to data sent within an HTTP request (rather than embedded within the URL). Specifically, there will be quite a bit of data (actually, a stringified XML file) ...
0
votes
0answers
27 views

BreezeJS - results from multiple linq queries into a single object

I'm wondering if it is possible to take the results of multiple queries, and append them into a collections object for breeze to query even further? here's an example of what I mean and using the ...
0
votes
2answers
30 views

Where should I plug in my custom DefaultContractResolver JSON.NET?

I have a WebAPI 2.0 project in ASP.Net in which I implemented a custom DefaultContractResolver so that I can control how my entities are serialized to JSON using JSON.Net; however I am unsure about ...
0
votes
2answers
72 views

WebAPI Method Reads Multiple Actions Found

I have two methods, both of which work perfectly one their own (i.e. when one of them is commented out) but when both are in the program, I get this error: {"Message":"An error has ...
0
votes
0answers
38 views

Web API action executes successfully but I see no response in the client application

From an ASP.NET MVC app, I make a POST request to an action on my Web API. The action in the API executes successfully. When I make the same request in a REST client such as Postman for Chrome, I see ...
0
votes
0answers
16 views

HTTP call return type issue

I am calling an action method in my controller from C# code. The action method returns "IHttpActionResult" but when I get the response from the place I call the method I get the response as ...
0
votes
1answer
22 views

ActionContext.ActionArguments Is Empty In IAuthenticationFilter

Background: I want to authenticate a POST request to my web API using an implementation of IAuthenticationFilter injected using Ninject. To authenticate a request I need access to request body. ...
0
votes
0answers
38 views

Sending parameters with HTTP post request

I am doing a HTTP request from my C# project to a controller I have. I am using webapi 2 in both cases. I manage to enter the controller's method but when I check the data I send it stays null or ...
0
votes
1answer
31 views

autofac not working for WebAPI 2 on azure website

I'm trying to setup my web api on azure, Everything is working file locally but when i deploy to azure I get the following error message : An error occurred when trying to create a controller of ...
0
votes
1answer
11 views

Call WebApi controller from another controller

So I have two projects in my solution. Both are WebApi. I have controllers in both and I can call them from the client side - javascript. The problem is that I need to call a method in the controller ...
0
votes
0answers
17 views

web api 2 with Asp.net identity custom

I customized the template web API 2 of VS2013 with regard to the use of ASP.NET Identity. Now I have my tables with my logic of saving information. I call these web api from a web application ...
1
vote
0answers
43 views

Sending overwriting response on HttpContext.Current is not a good idea?

I have a service where people use oData in order to filter data. Sample string goes like so $orderby=[SSN]&$top=3. When string cannot be parsed it throws InvalidCastException and I catch it and ...
1
vote
0answers
34 views

How do I limit API access to known client applications in a Web API 2 application?

I've created an application that is comprised of three main components: A .NET Web Api 2 project that provides several WebApiControllers. Some methods, like "Register" are open to anonymous access, ...
0
votes
0answers
23 views

Which entity types need Controllers generated for Web API OData Entity Framework solution?

I Have an Model First Entity Framework project. It contains Enums, Complex Types, and 1:1 relationships with inherited types. Example: I have a Coupon type. A coupon has either a single FixedOff ...
0
votes
1answer
17 views

Wrap XML root node with parent node

I have a .net Web Api 2 application that delivers data in XML. My problem: One of my classes looks like this: public class Horse { public string Name { get;set; } public string Category { ...
3
votes
2answers
48 views

How to get a flattened list back to breezejs through webapi2?

I have been struggling with this for a week now. I have a table of Person and Company in the DB. However, there is also a joiner Table of CompanyPerson which has some extra properties like ...
0
votes
3answers
30 views

WebAPI2 + Angular http GET - returning IEnumerable<Categories>. failed to serialize the response body for content type 'application/json

Greetings and thank you for reading my post ! Ok.. this is probably pretty easy for some, but for me... i'm learning this as we speak and find some of this pretty strange and hard ;) Here is the ...
0
votes
1answer
36 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
34 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 ...
1
vote
1answer
43 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
31 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
2answers
36 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: ...
1
vote
0answers
35 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
17 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
33 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
47 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 ...
0
votes
0answers
25 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; } ...
1
vote
2answers
61 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
46 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
41 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
43 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
26 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
51 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
1answer
32 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
47 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
18 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) => ...
0
votes
0answers
33 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
48 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
33 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 ...
0
votes
2answers
49 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
2answers
72 views

Model validation - Why ModelState.IsValid always returns true even when no values are supplied?

This is regarding WEBAPI and the following is my Model class. public class Request { public int Id { get; set; } public string Name { get; set; } [Required] ...
1
vote
0answers
53 views

Can you post an anonymous object as json to a webapi method and it match the properties of the json object to the parameters of the webapi call?

Can I have a webapi method [Route("someroute")] public void SomeMethod(string variable1, int variable2, Guid variable3) { //... Code here } simple json var jsonvariable = new { ...
7
votes
1answer
110 views

Uniform, consistent error responses from ASP.Net Web API 2

I'm developing a Web API 2 application and I'm currently trying to format error resposnes in a uniform way (so that the consumer will also know what data object/structure they can inspect to get more ...
1
vote
2answers
95 views

Ninject error in WebAPI 2.1 - Make sure that the controller has a parameterless public constructor

I have the following packages and their dependencies installed in my WebAPI project: Ninject.Web.WebApi Ninject.Web.WebApi.OwinHost I am running this purely as a web-api project. No MVC. When I ...
0
votes
3answers
75 views

Downloading File With Web API using Jquery Post

I have a web Api function that returns a file stream [HttpPost] public HttpResponseMessage DownloadDocument([FromBody] parameters) { try { var stream = ...
0
votes
1answer
28 views

Entity context provider metadata does not contains error message

I have a class order which contains OrderNo property. I have just set Required field validation with set necessary message. private string _OrderNo; [Required(ErrorMessage="Order No Is ...
3
votes
4answers
186 views

Model validation in Web API - Exception is thrown with out a throw statement?

I have seen the model validation from here (Under section: Handling Validation Errors). The code-snippet is as below in Web API public class ValidateModel : ActionFilterAttribute { ...