我有一个 Azure Blob 存储,我想在其中上传一些文件。
Index.cshtml
@using (Html.BeginForm("File_post", "MyController", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div class="editor-label">
<p>
<input type="file" name="file" />
</p>
<input type="submit" value="Upload" />
</div>
}
MyController.cs
public ActionResult File_post(HttpPostedFileBase file)
{
CloudBlobContainer blobContainer = Initialize(); // This Initialize my blobContainer
CloudBlockBlob blob;
blob = blobContainer.GetBlockBlobReference("myfile");
blob.UploadFromStream(file.InputStream);
Return("Index");
}
我用 3.5Mo 文件进行了测试,它甚至可以使用 20Mo 文件。现在我尝试使用 33Mo,Firefox 给出了基本错误: 连接已重置...
编辑:当我输入时
public ActionResult File_post(HttpPostedFileBase file)
{
Return("Index");
}
它给了我同样的错误,所以我认为这不是由我的 C# 代码引起的。
有什么想法吗?非常感谢!
最佳答案
您需要修改 web.config 以允许在 ASP.NET 和 IIS 中上传大文件(以下示例将允许上传 50MB 的文件):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="51200" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="51200000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
关于c# - Azure Blob 存储上传失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12616885/