簡體   English   中英

在 web 頁面 c# 代碼中顯示長 HTML 文本

[英]Display long HTML text in a web page c# code

我正在使用 C#.net

我有網頁,此頁面有“報告 ID”的列表視圖

請求的功能是當用戶單擊列表框中的報告 id 時,報告文本應顯示在 div 中。

報告文本為 HTML 格式(相當長,大約 16,000,000 個字符)

當我單擊列表框中的報告 ID 時

我收到這個錯誤

在此處輸入圖像描述

我添加了

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

但仍然得到同樣的錯誤!

如何解決?

我找到了答案

在系統中。web

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

並在 system.webServer

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
</security>

這可能對你有幫助!

<configuration>
  <system.web>
    <httpRuntime targetFramework="4.5.2" maxRequestLength="1048576"/>
  </system.web>
</configuration>

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

規則:

  • maxRequestLength(以 kb 表示)值必須與 maxAllowedContentLength(以字節表示)匹配。
  • 大多數時候您的 system.web 部分可能已經包含“httpRuntime”。 將您的 targetFramework 設置為您使用的 .net 的版本。

筆記:

  • maxRequestLength 的默認值為 4096 (4mb)。 最大值為 2,147,483,647
  • maxAllowedContentLength 的默認值為 30,000,000(大約 30mb)。 最大值為 4,294,967,295

暫無
暫無

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

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