ASP.NET上载大小限制

问题描述 投票:0回答:1

我试图在项目的Web.config中修改上传大小限制添加行:

<system.web>

<httpRuntime 
  maxRequestLength="512000"
  executionTimeout="3600"
/>
  ...

</system.web>

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

就像我在大多数地方发现的一样但是,当我尝试上传它仍然无法正常工作。当我尝试上传它时,给出了以下错误:

'/'应用程序中的服务器错误。超出最大请求长度。描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Web.HttpException:超出最大请求长度。

来源错误:

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

堆栈跟踪:

[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 request)+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, List1 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 state)+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
System.Web.Mvc.Async.WrappedAsyncResultBase
1.Begin(AsyncCallback回调,对象状态,Int32超时)+128 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
System.Web.Mvc.Async.WrappedAsyncResultBase
1.Begin(AsyncCallback回调,对象状态,Int32超时)+128 System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext,AsyncCallback callback,Object state)+374 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext,AsyncCallback callback,Object state)+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
System.Web.Mvc.Async.WrappedAsyncResultBase
1.Begin(AsyncCallback callback,Object state,Int32 timeout)+128 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 step,Boolean&completedSynchronously)+159

asp.net .net asp.net-mvc
1个回答
1
投票

正如我在上面的评论中解决的那样,如果您正在使用MVC,则应确保编辑主web.config文件而不是Views文件夹中的文件。

© www.soinside.com 2019 - 2024. All rights reserved.