ASP.MVC CORE网站的最大上传大小 [英] Max upload size for ASP.MVC CORE website

查看:101
本文介绍了ASP.MVC CORE网站的最大上传大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为ASP.NET CORE应用程序设置最大上传大小?

How can I set maximum upload size for an ASP.NET CORE application?

过去,我可以像这样在web.config文件中设置它:

In the past I was able to set it in web.config file like this:

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="52428800" />
        </requestFiltering>
    </security>
</system.webServer>

推荐答案

两种方法可以做到:

1.使用应用程序明智的设置-在配置服务方法中.

1.Using application wise settings - in the > configure services method.

services.Configure<FormOptions>(options =>
{
    options.MultipartBodyLengthLimit = 52428800;
});

2.使用RequestFormSizeLimit属性-用于特定操作. -尚未以官方包装提供 非官方

2.Using RequestFormSizeLimit attribute - for specific actions. - It is not yet available in official package Unofficial

这篇关于ASP.MVC CORE网站的最大上传大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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