gpt4 book ai didi

asp.net-mvc - System.Web.HttpException (0x80004005) : Maximum request length exceeded

转载 作者:行者123 更新时间:2023-12-03 22:16:35 28 4
gpt4 key购买 nike

我正在尝试在 ASP.NET MVC 5 应用程序中上传大小为 5.25 MB 的 mp4 视频文件。

我已尝试将此添加到 Web.config 文件中,该文件在大多数情况下已成为此问题的公认答案。

<system.web>
<!-- This will handle requests up to 1024MB (1GB) -->
<httpRuntime maxRequestLength="1048576" />
</system.web>

我也尝试在 Web.config 中设置超时
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

但是,当我上传文件时,我收到 System.Web.HttpException (0x80004005): Maximum request length exceeded.
也许需要在 Controller 或 View 中设置一些东西?

Controller :
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
if (fileName != null)
{
var path = Path.Combine(Server.MapPath("~/Content/Videos"), fileName);
file.SaveAs(path);
}
}
return RedirectToAction("Index");
}

看法:
@using (Html.BeginForm("Edit", "Posts", FormMethod.Post, new { enctype =  "multipart/form-data" }))
{
<input type="file" name="file" />
<input type="submit" value="OK" />
}

你如何在 ASP.NET MVC 5 中上传视频文件?

最佳答案

尝试在 web.config 中添加它(以字节为单位!):

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

关于asp.net-mvc - System.Web.HttpException (0x80004005) : Maximum request length exceeded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26442738/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com