【问题标题】:Error On Postback While Uploading a File上传文件时回发错误
【发布时间】:2012-04-11 21:04:57
【问题描述】:

我有一个 ASP.NET 4.0 Web 应用程序,用户可以在其中将视频上传到服务器。我有一个 FileUpload 控件和 2 个 DropDownLists。

用户首先从FileUpload控件中选择要上传的视频,然后他/她从DropDownList1(类别列表)中选择一个类别。用户选择一个类别后,我用子类别填充第二个DropDownList

当我选择要上传的文件并从DropDownList 中选择一个类别时,页面在回发后与服务器断开连接。如果我执行相同的场景没有选择要上传的文件,我会成功填充第二个组合。

这是我的代码:

 <tr>
        <td style="text-align: left;" class="style9" colspan="2">
            <asp:Label ID="Label1" runat="server" Text="Video" Width="80px"></asp:Label>
            <asp:FileUpload ID="FileUploadVideo" runat="server" ViewStateMode="Enabled" />
        </td>
        <td style="text-align: left;" class="style4">
            <asp:Label ID="Label3" runat="server" Text="Category" Width="80px"></asp:Label>
            <br />
            <asp:DropDownList ID="cmbCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="cmbCategory_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
        <td style="text-align: right;">
            <asp:Label ID="Label6" runat="server" Text="Subcategory" Width="80px"></asp:Label>
            <br />
            <asp:DropDownList ID="cmbSubcategory" runat="server">
            </asp:DropDownList>
        </td>
    </tr>

任何帮助将不胜感激。

【问题讨论】:

    标签: asp.net postback


    【解决方案1】:

    由于您正在上传视频,我想这是由于文件大小而出错。 ASP.NET 应用程序的默认最大文件大小为 4MB。您可以在 web.config 的 &lt;system.web&gt; 部分添加类似的内容以增加默认值:

    <system.web>
      <httpRuntime executionTimeout="240" maxRequestLength="20480" />
    </system.web>
    

    这允许上传一个 20MB 的文件。

    欲了解更多信息,请查看这篇文章:Large file uploads in ASP.NET

    【讨论】:

    猜你喜欢
    • 2018-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多