Django + iis 上传文件时发生未显示页面,因为请求实体过大

Posted Jason_WangYing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django + iis 上传文件时发生未显示页面,因为请求实体过大相关的知识,希望对你有一定的参考价值。

Django + iis 上传文件时发生413.1错误 未显示页面,因为请求实体过大


通过iis 部署好的Django 项目,在调用接口上传资料的时候,突然报错:“HTTP 错误 413.1 -Request Entity Too Large" ,显示请求实体太大异常。
 

1 在项目主目录下创建web.config文件,添加以下内容:


<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="1048576000" />
                </requestFiltering>
            </security>
            <handlers>
                <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\\Users\\Administrator\\.virtualenvs\\Python-LxgTLIVq\\Scripts\\python.exe|E:\\Python\\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
            </handlers>
        </system.webServer>
        <appSettings>
            <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
            <add key="PYTHONPATH" value="E:\\Python" />
            <add key="DJANGO_SETTINGS_MODULE" value="workjob.settings" />
        </appSettings>
    </configuration>

maxAllowedContentLength=“1048576000” ,我这里将最大允许内容长度配置为1000M。

2 大文件的话因为上传时间有可能会增长,可能会报错:“HTTP 错误 500.0 - Internal Server Error”FastCGI 进程超过了配置的请求超时时限。所以还需要配置下相应时间

此刻再启动IIS后,发现问题解除,可以正常上传文件了。(我是这样解决的,如果大家有其他的更好的方法欢迎大家一起讨论留言交流。)

以上是关于Django + iis 上传文件时发生未显示页面,因为请求实体过大的主要内容,如果未能解决你的问题,请参考以下文章

页面未显示,因为请求实体在 IIS 上太大

WebService接口上传文件提示未显示页面,因为请求实体过大

IIS 配置问题

IIS 8.5 请求实体太大在 IE 11 中发生,但在 Chrome 中没有

新网站未在 IIS 8.5 中显示默认页面

事件代码:4011 尝试使用 Handler 上传文件时发生未处理的访问异常