我尝试在项目的Web.config中修改上传大小限制 添加行:
<system.web>
<httpRuntime
maxRequestLength="512000"
executionTimeout="3600"
/>
...
</system.web>
<system.webServer>
...
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="15728640" />
</requestFiltering>
</security>
就像我在大多数地方找到的一样。 但是,当我尝试上传它仍然无法正常工作。 当我尝试上传时,会出现以下错误:
>'/'应用程序中的服务器错误。超出最大请求长度。描述:执行期间发生未处理的异常 当前的网络请求。请查看堆栈跟踪了解更多信息 有关错误的信息以及它在代码中的起源。异常详细信息:System.Web.HttpException:最大请求长度 超出。
来源错误:
执行期间生成了未处理的异常 当前的网络请求。有关的来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
堆栈追踪:
[HttpException(0x80004005):超出最大请求长度。]
System.Web.HttpRequest.GetEntireRawContent()+9904940
System.Web.HttpRequest.GetMultipartContent()+63
System.Web.HttpRequest.FillInFormCollection()+160
System.Web.HttpRequest.EnsureForm()+ 69
System.Web.HttpRequest.get_Form()+13
System.Web.HttpRequestWrapper.get_Form()+ 14
System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase 请求)+121
System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext controllerContext,MethodInfo methodInfo)+37
System.Web.Mvc.HttpPostAttribute.IsValidForRequest(ControllerContext controllerContext,MethodInfo methodInfo)+39
System.Web.Mvc.ActionMethodSelectorBase.IsValidMethodSelector(ReadOnlyCollection1 attributes, ControllerContext controllerContext, MethodInfo method) +54 System.Web.Mvc.ActionMethodSelectorBase.RunSelectionFilters(ControllerContext controllerContext, List
1 methodInfos)+118
System.Web.Mvc.ActionMethodSelectorBase.FindActionMethods(ControllerContext controllerContext,String actionName)+166
System.Web.Mvc.ActionMethodSelectorBase.FindActionMethod(ControllerContext controllerContext,String actionName)+31
System.Web.Mvc.Async.ReflectedAsyncControllerDescriptor.FindAction(ControllerContext controllerContext,String actionName)+54
System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext,ControllerDescriptor controllerDescriptor,String actionName)+203
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext,String actionName,AsyncCallback callback,Object 国家)+136
System.Web.Mvc.Controller.b__1c(AsyncCallback的 asyncCallback,Object asyncState,ExecuteCoreState innerState)+25
System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
1.Begin(的AsyncCallback 回调,对象状态,Int32超时)+128
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback回调, 对象状态)+465
System.Web.Mvc.Controller.b__14(AsyncCallback的 asyncCallback,Object callbackState,Controller controller)+18
System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
1.Begin(的AsyncCallback 回调,对象状态,Int32超时)+128
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback回调,对象状态)+374
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(的RequestContext requestContext,AsyncCallback回调,对象状态)+16
System.Web.Mvc.MvcHandler.b__4(AsyncCallback的 asyncCallback,Object asyncState,ProcessRequestState innerState)+52 System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
1.Begin(的AsyncCallback 回调,对象状态,Int32超时)+128
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext,AsyncCallback回调,对象状态)+384
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback回调,对象状态)+48
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext的 context,AsyncCallback cb,Object extraData)+16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)+48 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步,布尔&amp; completedSynchronously)+159
答案 0 :(得分:1)
正如我在上面的评论中解决的那样,如果您正在使用MVC,则应确保编辑主web.config文件而不是Views文件夹中的文件。