2013-02-19 61 views
0

我正在使用fineuploader上傳文件。對於200MB以下的文件,一切正常。一切都失敗了。創建一個新文件,但它是空的(意思是0kb)上傳文件在.net MVC

已經修改我的web.config允許上傳500mb。但似乎沒有幫助。

的web.config:

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

<httpRuntime targetFramework="4.5" maxRequestLength="512000" executionTimeout="900" requestLengthDiskThreshold="512000" /> 

控制器:200MB以上

[HttpPost] 
public ActionResult Upload(string qqfile) 
{ 
    try 
    { 
     Stream stream = Request.Files.Count > 0 ? Request.Files[0].InputStream : Request.InputStream; 

     string filePath = Path.Combine(@"C:\Temp\100", qqfile); 
     using (Stream file = System.IO.File.OpenWrite(filePath)) 
     { 
      stream.CopyTo(file); 
     } 
.... 

爲什麼我不能上傳文件?

+0

http://forums.asp.net/t/1646283.aspx/1和http://stackoverflow.com/a/6472631/118298 2可能有所幫助 – Yasser 2013-02-19 17:02:40

回答

0

想通了: 這是一個web.config設置:

的web.config:

<httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="90" requestLengthDiskThreshold="2147483647" /> 

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

感謝阿拉法特指着我在正確的方向

0

首先想到的是IIS中的限制。在IIS7中的「集成模式」之前,必須處理IIS-MetaBase以設置IIS屬性。

如果您在「集成模式」下運行網站或使用VS Development Webserver(基於Cassini),它可能會工作,如果您在「經典模式」下運行生產,它將不使用集成配置並回到元數據庫。如果是,並且您尚未編輯元數據庫,則通過默認元數據庫上傳限制進行的任何上傳都將失敗。

從你的代碼/配置/問題我不能確定你有問題的網站正在運行的模式 - 這可能是至關重要的回答你的問題 - 所以請提供這些細節。