使用ASP.NET的WebAPI上传文件(最高可达10MB文件大小) [英] Uploading files (up to 10Mb file size) with ASP.NET webAPI

查看:132
本文介绍了使用ASP.NET的WebAPI上传文件(最高可达10MB文件大小)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在包含一个Web API控制器VS2012 MVC4项目。该项目将在IIS服务器上予以公布。

I work on a VS2012 MVC4 project containing a Web API controller. This project will be published on an IIS server.

我需要让用户上传文件。这个问题是一个Web API上限为4MB最大文件大小上传。我读(例如这里:<一href=\"http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx\">http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx)我们可以通过扩展自身承载Web API此限制(在这种情况下,上传文件最大为2GB)。我不希望自主机我的WebAPI,因为我想举办这我的IIS Web服务器上,所以我觉得这是不适合我的情况,对吧?所以我能上传更大的文件超过4MB办?

I need to allow users to upload files. The problem is a web API is limited up to 4MB maximum file size upload. I read (for example here: http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx) that we can extend this limitation by self hosting the web API (in this case file upload up to 2GB). I don't want self host my webAPI because I want to host it on my IIS web server so I think this is not suitable for my situation, right? So what can I do for uploading files bigger than 4MB?

如果可能,我寻找一个HTML5解决方案(与drag'n下降)。

If possible I search for an HTML5 solution (with drag'n drop).

到目前为止,我没有发现解决方案可以让我做到这一点。

So far none of the solutions I found allows me to accomplish this.

感谢您的帮助。

推荐答案

也许并不清楚,但实际上的博客网址是指IIS。你需要寻找在Web.config中的以下2设置,以增加上传大小:

Probably it was not clear but actually the blog url is referring to IIS. You need to look for the following 2 settings in Web.config to increase the upload size:

注意(的maxRequestLength =大小以KB为单位):结果
&LT;&的System.Web GT;
        &LT;的httpRuntime targetFramework =4.5maxQueryStringLength =的maxRequestLength =maxUrlLength =/&GT;

注意(maxAllowedContentLength以字节为单位)
&LT; system.webServer&GT;
        &LT;安全&GT;
        &LT;&的requestFiltering GT;
        &LT; requestLimits maxAllowedContentLength =maxQueryString =maxUrl =/&GT;

这篇关于使用ASP.NET的WebAPI上传文件(最高可达10MB文件大小)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆