gpt4 book ai didi

c# - 为特定路由增加 ServiceStack 中的 maxRequestLength

转载 作者:太空狗 更新时间:2023-10-29 19:44:05 28 4
gpt4 key购买 nike

所以我最近写了一个简单的服务来上传文件到我的服务器。一切正常。我的 web.config 如下所示(最大上传大小限制为 20 MB):

<configuration>
<system.web>
<httpRuntime maxRequestLength="20480" executionTimeout="600" />
<httpHandlers>
<add path="api*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
...
</system.web>
</configuration>

我所有的路由都以/api/开头,例如我的上传服务在/api/documents/upload。

现在我的问题是:是否可以为不同的服务定义不同的上传大小? (在我的示例中,每个服务限制为 20 MB!)

我尝试了一些带有 location-tag 的东西,但它对 httpRuntime-tag 不起作用。有人已经尝试过这样的事情了吗?

最佳答案

使用 location元素,它应该可以工作(检查没有 ~/ 的路径)

<configuration>
<location path="api/documents/upload">
<system.web>
<httpRuntime maxRequestLength="20480" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="20971520" />
</requestFiltering>
</security>
</system.webServer>
</location>
</configuration>

关于c# - 为特定路由增加 ServiceStack 中的 maxRequestLength,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20902642/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com