HttpException (0x80004005): 超过了最大请求长度

HttpException (0x80004005): 超过了最大请求长度,解决方案:

方案1:

在web.config中找到相应节点,插入一行代码即可:实际上是服务器的延时不够的问题,再就是asp.net默认最大上传文件大小为4096 k  
 
<system.web>
<!-- 指示 ASP.NET 支持的最大文件上载大小。
该限制可用于防止因用户将大量文件传递到该服务器而导致的拒绝服务攻击。
指定的大小以 KB 为单位。默认值为 4096 KB (4 MB)。
此处改为40M大小的文件上传限制。
-->
<httpRuntime maxRequestLength = "40960" useFullyQualifiedRedirectUrl="true"/>
</system.web>


方案2:
直接修改 c:\winnt\microsoft.net\dotnetframework\1.xxx.xx\config目录下的machine.config     文件, 查找"<httpruntime" 在这一行将 maxRequestLength的值改为理想的值,比如想要8M,就输入8192.       
  这样,你的任何一个 web 工程都可以上传最大8M的文件。

Exception Group Traceback (most recent call last): | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\_utils.py", line 76, in collapse_excgroups | yield | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 186, in __call__ | async with anyio.create_task_group() as task_group: | │ │ └ <anyio._backends._asyncio.TaskGroup object at 0x00000168B3F1F4F0> | │ └ <function create_task_group at 0x00000168A54857E0> | └ <module 'anyio' from 'D:\\dev\\EquipmentRegistryDataPlatform\\venv\\lib\\site-packages\\anyio\\__init__.py'> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 815, in __aexit__ | raise BaseExceptionGroup( | └ <class 'exceptiongroup.BaseExceptionGroup'> | | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 403, in run_asgi | result = await app( # type: ignore[func-returns-value] | └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x00000168A4F34760> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__ | return await self.app(scope, receive, send) | │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E860>> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <fastapi.applications.FastAPI object at 0x00000168B3AF1D50> | └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x00000168A4F34760> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\fastapi\applications.py", line 1054, in __call__ | await super().__call__(scope, receive, send) | │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E860>> | │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\applications.py", line 113, in __call__ | await self.middleware_stack(scope, receive, send) | │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E860>> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x00000168B3D038E0> | └ <fastapi.applications.FastAPI object at 0x00000168B3AF1D50> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\errors.py", line 187, in __call__ | raise exc | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\errors.py", line 165, in __call__ | await self.app(scope, receive, _send) | │ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x00000168A65497E0> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <starlette.middleware.cors.CORSMiddleware object at 0x00000168B3D038B0> | └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x00000168B3D038E0> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\cors.py", line 93, in __call__ | await self.simple_response(scope, receive, send, request_headers=headers) | │ │ │ │ │ └ Headers({'host': '172.23.49.43:9999', 'connection': 'keep-alive', 'content-length': '117', 'pragma': 'no-cache', 'cache-contr... | │ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x00000168A65497E0> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <function CORSMiddleware.simple_response at 0x00000168B3AF7490> | └ <starlette.middleware.cors.CORSMiddleware object at 0x00000168B3D038B0> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\cors.py", line 144, in simple_response | await self.app(scope, receive, send) | │ │ │ │ └ functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at 0x00000168B3D038B0... | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <app.core.middlewares.BackGroundTaskMiddleware object at 0x00000168B3D03850> | └ <starlette.middleware.cors.CORSMiddleware object at 0x00000168B3D038B0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 28, in __call__ | await self.handle_http(scope, receive, send) | │ │ │ │ └ functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at 0x00000168B3D038B0... | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <function SimpleBaseMiddleware.handle_http at 0x00000168B3B141F0> | └ <app.core.middlewares.BackGroundTaskMiddleware object at 0x00000168B3D03850> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 38, in handle_http | await response(scope, receive, send_wrapper) | │ │ │ └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x00000168A6549A20> | │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x00000168B3F1E... | │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 185, in __call__ | with collapse_excgroups(): | └ <function collapse_excgroups at 0x00000168A56A4940> | | File "C:\Program Files\Python310\lib\contextlib.py", line 153, in __exit__ | self.gen.throw(typ, value, traceback) | │ │ │ │ │ └ <traceback object at 0x00000168B523ABC0> | │ │ │ │ └ ExceptionGroup('unhandled errors in a TaskGroup', [TypeError("Unable to apply constraint 'max_length' to supplied value 2025-... | │ │ │ └ <class 'exceptiongroup.ExceptionGroup'> | │ │ └ <method 'throw' of 'generator' objects> | │ └ <generator object collapse_excgroups at 0x00000168B507E1F0> | └ <contextlib._GeneratorContextManager object at 0x00000168B3F1E830> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\_utils.py", line 82, in collapse_excgroups | raise exc | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 187, in __call__ | response = await self.dispatch_func(request, call_next) | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | │ │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | │ └ <bound method APILoggerMiddleware.dispatch of <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0>> | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\_utils.py", line 82, in collapse_excgroups | raise exc | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 187, in __call__ | response = await self.dispatch_func(request, call_next) | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | │ │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | │ └ <bound method APILoggerMiddleware.dispatch of <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0>> | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | raise exc | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 187, in __call__ | response = await self.dispatch_func(request, call_next) | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | │ │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | │ └ <bound method APILoggerMiddleware.dispatch of <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0>> | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 187, in __call__ | response = await self.dispatch_func(request, call_next) | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | │ │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | │ └ <bound method APILoggerMiddleware.dispatch of <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0>> | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | │ │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | │ └ <bound method APILoggerMiddleware.dispatch of <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0>> | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | │ └ <starlette.middleware.base._CachedRequest object at 0x00000168B3F1E950> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x00000168A6549990> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | raise app_exc | └ TypeError("Unable to apply constraint 'max_length' to supplied value 2025-08-24 16:00:00+00:00") | | raise app_exc | └ TypeError("Unable to apply constraint 'max_length' to supplied value 2025-08-24 16:00:00+00:00") | | └ TypeError("Unable to apply constraint 'max_length' to supplied value 2025-08-24 16:00:00+00:00") | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 149, in coro | await self.app(scope, receive_or_disconnect, send_no_error) | │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x00000168A654AA70> | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x00000168A6549900> | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('172.23.49.43', 9999), ... | │ └ <app.core.middlewares.APILoggerAddResponseMiddleware object at 0x00000168B3D03730> | └ <app.core.middlewares.APILoggerMiddleware object at 0x00000168B3D037F0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 28, in __call__ | await self.handle_http(scope, receive, send) | │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x00000168A654AA70> | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x00000168A654WARNING: StatReload detected changes in 'app\api\v1\zentao\zt_materiallib.py'. Reloading...
最新发布
08-26
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值