wcf-web-api

Post large string to Web API controller

梦想的初衷 提交于 2020-01-16 00:56:26
问题 I have a following controller public class MyController : ApiController { [HttpPost] public string LoadData(string currentState) { } } I post some data from browser with jQuery.post . The length of the state should be 29915 characters, but currentState variable has only 21621 characters. The end of the string is lost. I checked if browser sends all data to the server and it does. So the problem somewhere on the server. 回答1: Setting the ReadBufferSize helps: protected void Application_Start

Where can I find up-to-date documentation about the WCF Web API?

 ̄綄美尐妖づ 提交于 2020-01-15 07:31:21
问题 I've been strugling with WCF to do REST the way I want it to work. And apparently so has quite a few others. I've heard about the WCF Web Api project, but wrongly dismissed it without looking too closely at it. Sadly, now that I'm looking at it I find that the documentation is rather outdated. Like, this blog post has some nice information, but classes have changed, parameters have changed, in short, design has changed. So I've been using an old example of how to plug in Json.NET (newtonsoft)

Setting up Ninject with the new WCF Web API

巧了我就是萌 提交于 2020-01-03 08:44:08
问题 So I've been playing around with the latest release of the WCF Web API and decided I wanted to dive into implementing Ninject with it. Based off what I've read I need to implement the interface IResourceFactory which demands the following methods: public object GetInstance(System.Type serviceType, System.ServiceModel.InstanceContext instanceContext, System.Net.Http.HttpRequestMessage request); public void ReleaseInstance(System.ServiceModel.InstanceContext instanceContext, object service); So

C# WCF Web Api 4 MaxReceivedMessageSize

橙三吉。 提交于 2020-01-02 03:34:26
问题 I am using the WCF Web Api 4.0 framework and am running into the maxReceivedMessageSize has exceeded 65,000 error. I've updated my webconfig to look like this but because I am uisng the WCF Web Api I think this isn't even used anymore as I am no longer using a webHttpEndpoint? <standardEndpoints> <webHttpEndpoint> <!-- Configure the WCF REST service base address via the global.asax.cs file and the default endpoint via the attributes on the <standardEndpoint> element below -->

Set Accepts in HTTP Download Request Header

风流意气都作罢 提交于 2020-01-01 16:52:13
问题 I have a WCF Web Api endpoint that returns an invoice: http://localhost/api/invoice/23 The format it returns is that of the accepts header in the request. If the Javascript wants JSON or XML then it just sets this in the accept header. This is how WCF Web Api seems to work. I've added a PDF formatter to invoice so that when asking for application/pdf it will get a rendered pdf file stream back with the appropriate MIME type. This works fine and I can test it in fiddler. I need the user to

Post an empty body to REST API via HttpClient

限于喜欢 提交于 2019-12-31 17:35:20
问题 The API I'm trying to call requires that I do a POST but with an empty body. I'm new to using the WCF Web API HttpClient and I can't seem to find out the write code that would do a post with an empty body. I find references to some HttpContent.CreateEmpty() method, but I don't think that is for the Web API HttpClient code since I can't seem to find that method. 回答1: Use StringContent or ObjectContent which derive from HttpContent or you can use null as HttpContent (see this comment). 回答2: Did

Consuming WebApi in MVC3

微笑、不失礼 提交于 2019-12-30 01:32:10
问题 Using WebApi, what is the best way to consume a service in a MVC client? If the response comes back as: <?xml version="1.0" encoding="UTF-8"?> <ArrayOfContact xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Contact> <Id>1</Id> <Name>Bilbo Baggins</Name> </Contact> <Contact> <Id>2</Id> <Name>Frodo Baggins</Name> </Contact> </ArrayOfContact> How can I take that, get my Contacts out and list them in a MVC3 Razor View using @Model? There's a

System.Net.Http.HttpClient caching behavior

青春壹個敷衍的年華 提交于 2019-12-29 07:24:42
问题 I'm using HttpClient 0.6.0 from NuGet. I have the following C# code: var client = new HttpClient(new WebRequestHandler() { CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.CacheIfAvailable) }); client.GetAsync("http://myservice/asdf"); The service (this time CouchDB) returns an ETag value and status code 200 OK. There is returned a Cache-Control header with value must-revalidate Update, here are the response headers from couchdb (taken from the visual studio debugger): Server:

JSON.NET Serializer for WCF REST Services

寵の児 提交于 2019-12-28 02:59:25
问题 I am trying to use the NETFx Json.NET MediaTypeFormatter nuget package to swap out the default DataContractJsonSerializer in my WCF REST service (4.0 framework). I downloaded the package in my project and added the following lines of code in the Global.asax file. void Application_Start(object sender, EventArgs e) { RegisterRoutes(); // Create Json.Net formatter serializing DateTime using the ISO 8601 format var serializerSettings = new JsonSerializerSettings(); serializerSettings.Converters

Using the WCF HTTP Web API, UriTemplateMatch is always null

回眸只為那壹抹淺笑 提交于 2019-12-23 01:20:12
问题 I've setup my service according to the latest tutorials I've found, and everything seems to work fine. HOWEVER, In order to access the WebOperationContext.Current.IncomingRequest.UriTemplateMatch class which contains the QueryParameters collection (e.g. ?name=tom&age=20), I need to have the service configured to use WebHttpBehavior. The only way I've managed to get this to work is to self host it using WebServiceHost from a console application. I can't get it to work from the web.config or