【发布时间】:2018-02-01 09:59:31
【问题描述】:
我目前正在使用多行文本框让我的用户向我提交非常大的数据字符串。我注意到多行文本框的最大容量约为 40 亿个字符或可用内存(以较小者为准。我用于测试目的的字符串远低于 40 亿个字符)。但是我仍然无法提交我的数据。当我单击提交按钮时,数据被编程为写入根文件夹中的 .txt 文件,并使用标签将数据打印在屏幕上:
<asp:Label ID="lblmsg" Font-Bold="false" style="white-space:pre;" runat="server" Text=""></asp:Label>
在 Safari 上,我在提交之前收到所需的验证错误。 (如果我禁用验证码,我会在提交时重新路由到我的网络应用程序的错误页面。)
在 Chrome 上我没有收到验证错误,我点击提交,输入被上传到 100%,然后我得到我的网络应用程序的错误页面。
我在想,我的错误可能是任何可能的原因:
1) 标签或网络应用程序都无法在一个页面上处理那么多数据。或者:
2) 我正在使用基本的 Microsoft Azure Web 应用服务计划来托管我的 Web 表单。也许我遇到了一个处理限制。
这是我的验证器代码:(尽管我认为这不是问题。
<asp:RequiredFieldValidator ValidationGroup="g1" ControlToValidate="txtvalue" ForeColor="Red" ID="RequiredFieldValidator1" runat="server" ErrorMessage="empty or contains more than 4,294,967,295 characters (or an amount based on available memory, whichever is smaller)."></asp:RequiredFieldValidator>
<br /> <asp:RequiredFieldValidator ValidationGroup="g1" ControlToValidate="txtvalue2" ForeColor="Red" ID="RequiredFieldValidator2" runat="server" ErrorMessage=" empty or contains more than 4,294,967,295 characters (or an amount based on available memory, whichever is smaller.)"></asp:RequiredFieldValidator>
<br /> <asp:RegularExpressionValidator ValidationGroup="g1" ForeColor="Red" ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtvalue" ErrorMessage="Invalid delimiter format. Make sure to use one consistent delimeter: (comma, space, or tab)." ValidationExpression="^\s*-?[0-9][0-9]*\s*(?=([., \t]))(?:\s*(?:\1|\r?\n)\s*-?[0-9][0-9]*)+\s*$"></asp:RegularExpressionValidator>
<br /> <asp:RegularExpressionValidator ValidationGroup="g1" ForeColor="Red" ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtvalue2" ErrorMessage="Invalid delimiter format. Make sure to use one consistent delimeter: (comma, space, or tab)." ValidationExpression="^\s*-?[0-9][0-9]*\s*(?=([., \t]))(?:\s*(?:\1|\r?\n)\s*-?[0-9][0-9]*)+\s*$"></asp:RegularExpressionValidator>
这是我认为还可以的 web.config 代码:
<configuration>
<system.web>
<compilation targetFramework="4.5" />
<!-- 50MB in kilobytes, default is 4096 or 4MB-->
<httpRuntime maxRequestLength="1073741824" executionTimeout="3600" targetFramework="4.5" />
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- 50MB in bytes, default is 30000000 or approx. 28.6102 Mb-->
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
</system.webServer>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
这是我正在测试的输入的link。
【问题讨论】:
-
您在处理什么需要在您的网站上输入 40 亿个字符?
-
大约 3.8 GB。将粘贴复制到文本框中似乎有点多。
-
为什么不上传文件?我认为你是XY problem 中的陷阱。
-
@VDWWD 3.8gb 是多少?如果我将矩阵的内容复制到一个文本文件中,它只有 5mb(尽管我的矩阵不是 40 亿个字符)
-
@justinpees 40 亿个字符的纯文本大约是我相信的那个大小,但是你问的是更多的输入大小。 5 mb 远不及 4b 字符。
标签: asp.net webforms textbox multilinestring bigdata