asp.net-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

How to post ordered items without timeout to controller

拜拜、爱过 提交于 2020-01-15 18:46:53
问题 HTML5 offline ASP.NET MVC4 application allows to enter order quantities and submit order for customer. Product list rendered in browser contains about 4000 products. Only few products are ordered for particular order. Using code below request times out. Browser posts all products. Request takes too much time and is probably terminated by httpruntime ExecutionTimeout Server error log shows that all posted data is received. It looks like MVC model binder requires too much time to create product

Host Web Api in self hosted NServiceBus

人盡茶涼 提交于 2020-01-15 16:50:34
问题 I'm looking for how to use a self hosted NServiceBus, which starts and hosts Web Api. I can't seem to find any resources on it. Anyone care to point me to a direction or provide some examples? Thanks 回答1: Here is a sample app that walks though the various things you should know when self hosting NServiceBus https://github.com/SimonCropp/NServiceBus.SelfHost The main code is as follows class SelfHostService : ServiceBase { IStartableBus bus; static void Main() { using (var service = new

How to use dependency injection in ActionFilter Web API?

坚强是说给别人听的谎言 提交于 2020-01-15 09:56:52
问题 I am trying to get work with dependency injection into the action filter, but it seems not working I've registered the type in UnityConfig public static void RegisterComponents(IUnityContainer container) { GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); container.RegisterType<Domain.Contracts.IUserServices, Domain.UserServices>(new ContainerControlledLifetimeManager()); ... } The code is being called successfully, however, the instantiated object

How to convert a JSON object containing an array to C# Dictionary<string,string>?

萝らか妹 提交于 2020-01-15 09:47:27
问题 I am sending a request to a WebAPI using following code: client.PostAsync(baseAddress + path, new FormUrlEncodedContent(JsonConvert.DeserializeObject<Dictionary<string,string>>(form))) where client is an object of HttpClient class. This code is executed for all the requests to the WebApi. I am trying to send following data to the API: { "code":"GUEST", "category":"Indian", "sections":["01000000-0000-0000-0000-000000000000","02000000-0000-0000-0000-000000000000"], "date":"0001-01-01T00:00:00",

Solution: The length of the string exceeds the value set on the maxJsonLength property for POST action

回眸只為那壹抹淺笑 提交于 2020-01-15 09:33:10
问题 I've following code in MVC. In my POST action params will have huge data. So, I changed web.config accordingly but, I'm getting ERROR . Actual problem is controller is not even hitting when POST is called. I tried Following ways Override JsonResult followed Link. Here i couldn't see data which is sent from script. I'm getting NULL in base64 . controller.cs [System.Web.Mvc.HttpPost] public bool postImage(string base64) { return true; } web.config <system.web.extensions> <scripting>

ASP.NET Web Api. Controller not hit. No response at all. Approaches to diagnose?

ぐ巨炮叔叔 提交于 2020-01-15 09:10:37
问题 I have a controller method which was previously working and it's not clear what change, if any, has caused the following problem: The controller is not hit. There is no exception, no response, no status code or indeed any response from the server (checked in Fiddler). The request eventually times out. UPDATE See my answer below. Also see my follow up question: Web API Controller method executes to end. No HTTP response. Hangs 回答1: Is your project under source control? You mention that it was

ASP.NET Web API cannot return XML if the returned object has an IList<T> property

风流意气都作罢 提交于 2020-01-15 09:10:34
问题 I'm using ASP.NET Web API's ApiController to expose business logic as a Web service. I'm testing both XML and JSON, since we have demand for both, and I've been using Fiddler to test. I've narrowed it down to this: having an IList<T> property forces JSON for some reason, but changing the property to List<T> allows either JSON or XML. Unfortunately, I need these to use IList<T> , so how can I make XML out of objects with IList<T> properties? If I use the following HTML headers to GET http:/

ASP.NET Web Api. Controller not hit. No response at all. Approaches to diagnose?

ぃ、小莉子 提交于 2020-01-15 09:10:11
问题 I have a controller method which was previously working and it's not clear what change, if any, has caused the following problem: The controller is not hit. There is no exception, no response, no status code or indeed any response from the server (checked in Fiddler). The request eventually times out. UPDATE See my answer below. Also see my follow up question: Web API Controller method executes to end. No HTTP response. Hangs 回答1: Is your project under source control? You mention that it was

WebApi 2 Oauth2 Android client

点点圈 提交于 2020-01-15 07:24:48
问题 I want my android app to communicate with an Asp.net WebApi2 secured by Oauth2. All samples I've found only show how it is done for websites. I'm able to get an access token from the "/token" endpoint and I add this token to the http header in the Autorization attribute. However, I always get: "Authorization has been denied for this request." My Startup Auth looks like: public partial class Startup { public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; } public