上传大于4096 KB的文件失败!

时间:2011-05-21 14:52:06

标签: c# asp.net file-upload web-config

我正在使用visual Studio 2010建立一个asp.net(asp.net framework 4.0)webproject。在我的一个网页中,我使用了以下链接中的silverlight mulit文件上传器:

Silverlight Mulit File uploader

我将插件的最大上传大小设置为100 MB,如下面的代码所示。

 <object id="MultiFileUploader" data="data:application/x-silverlight-2," type="application/x-silverlight-2"
    width="465" height="220">
    <param name="source" value="../ClientBin/mpost.SilverlightMultiFileUpload.xap" />
    <param name="onerror" value="onSilverlightError" />
    <param name="initParams" value="MaxFileSizeKB=102400,MaxUploads=2,FileFilter=Bilder(*.jpg *.png *.gif*)|*.jpg;*.png;*.gif|Dokumente(*.pdf)|*.pdf|Videos(*.mpeg *.avi *.wma)|*.mpeg;*.avi;*.wma|Audio(*.mp3)|*.mp3,ChunkSize=4194304,CustomParams=yourparameters,DefaultColor=White" />
    <param name="background" value="white" />
    <param name="onload" value="pluginLoaded" />
    <param name="minRuntimeVersion" value="4.0.50401.0" />
    <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration: none">
        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
            style="border-style: none" />
    </a>
</object>
<iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>

我还在web.config文件中输入了一些条目:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
    </compilation>
        <httpRuntime maxRequestLength="102400" executionTimeout="360" />
    <sessionState
      mode="InProc"
      timeout="30"
      cookieless="false"
      cookieName="MMAdminPfynSession"/>
    <authentication mode="Windows"/>
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="104857600" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

每次上传大于4096 KB的文件时,上传过程都会失败。我按下ctrl-F5,从Visual Studio 2010开始我的webapplication。有什么想法吗?

Greez Marc

1 个答案:

答案 0 :(得分:5)

您需要增加maxRequestLengthexecution time

<httpRuntime maxRequestLength="102400" executionTimeout="360" />