asp.net-mvc-4

Can not find system.web.http

匆匆过客 提交于 2020-12-30 04:48:46
问题 I have to add a system.web.http assembly reference because I added the HttpConfiguration class to my unit test class library project. When I browse the Add reference dialog I can not find the system.web.http assembly. The class library project has the .Net 4.5.1 framework targeted. 回答1: in order to get the system.web.http you will need to install a nuget package in the nuget command line: Install-Package Microsoft.AspNet.WebApi.Core https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Core/

Upload file through WebApi fails for larger file

自古美人都是妖i 提交于 2020-12-26 08:16:33
问题 I'm trying to upload a file using WebApi. The byte[] is 1.6MB. For some reason my model is serialised to null. I suspect it's the filesize because it works with smaller files. Any ideas? This is what I'm using - where data is a model containing a byte[]. return HttpClient.PostAsJsonAsync<T>(requestUri, data) .ContinueWith(x => Handle<R>(x.Result), TaskContinuationOptions.AttachedToParent); 回答1: May be you have to change .config <system.web> <httpRuntime maxRequestLength="2097152"/> </system