How to get HttpClient to pass credentials along with the request?

I have a web application (hosted in IIS) that talks to a Windows service. The Windows service is using the ASP.Net MVC Web API (self-hosted), and so can be communicated with over http using JSON. The web application is configured to do impersonation, the idea being that the user who makes the request to the … Read more

Adding Http Headers to HttpClient

I need to add http headers to the HttpClient before I send a request to a web service. How do I do that for an individual request (as opposed to on the HttpClient to all future requests)? I’m not sure if this is even possible. var client = new HttpClient(); var task = client.GetAsync(“http://www.someURI.com”) .ContinueWith((taskwithmsg) … Read more

How to add/update child entities when updating a parent entity in EF

The two entities are one-to-many relationship (built by code first fluent api). public class Parent { public Parent() { this.Children = new List<Child>(); } public int Id { get; set; } public virtual ICollection<Child> Children { get; set; } } public class Child { public int Id { get; set; } public int ParentId { … Read more

Single controller with multiple GET methods in ASP.NET Web API

In Web API I had a class of similar structure: public class SomeController : ApiController { [WebGet(UriTemplate = “{itemSource}/Items”)] public SomeValue GetItems(CustomParam parameter) { … } [WebGet(UriTemplate = “{itemSource}/Items/{parent}”)] public SomeValue GetChildItems(CustomParam parameter, SomeObject parent) { … } } Since we could map individual methods, it was very simple to get the right request at … Read more

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 according to their string value without having to look at the enum every time. I tried DescribeAllEnumsAsStrings but the server then receives strings instead … Read more

Could not load file or assembly ‘System.Web.Http 4.0.0 after update from 2012 to 2013

I did the upgrade according to. http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 I get the error. Does any one else got this error? Server Error in “https://stackoverflow.com/” Application. Could not load file or assembly ‘System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An … Read more