簡體   English   中英

RequestSizeLimit(100_000_000) 不適用於 IIS

[英]RequestSizeLimit(100_000_000) not working on IIS

我有一個 rest API 使用 .net 5.0。 我想在一個端點中使用 [RequestSizeLimit(100_000_000)]。 使用 Kestrel 時它可以工作,但我想在 IIS 中使用它。 我錯過了什么? 重要提示:我的項目沒有web.config :此處未顯示任何解決方案: 在 Asp.Net 核心中增加上傳文件大小解決了我的問題。

RequestSizeLimit屬性允許您在代碼中定義最大請求大小,但它仍然受到服務器本身支持的最大請求大小的限制,因此您可以嘗試通過 iis 中的maxAllowedContentLength屬性設置請求大小。

您可以嘗試創建一個 web.config 文件,內容如下:

<system.webServer>
  <security>
    <requestFiltering>
      <!-- This will handle requests up to 50MB -->
      <requestLimits maxAllowedContentLength="52428800" />
    </requestFiltering>
   </security>
</system.webServer>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM