Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc ASP.NET MVC是否在子文件夹web.config中忽略maxRequestLength和maxAllowedContentLength?_Asp.net Mvc_Asp.net Mvc 3_File Upload_Iis 7_Web Config - Fatal编程技术网

Asp.net mvc ASP.NET MVC是否在子文件夹web.config中忽略maxRequestLength和maxAllowedContentLength?

Asp.net mvc ASP.NET MVC是否在子文件夹web.config中忽略maxRequestLength和maxAllowedContentLength?,asp.net-mvc,asp.net-mvc-3,file-upload,iis-7,web-config,Asp.net Mvc,Asp.net Mvc 3,File Upload,Iis 7,Web Config,我在web.config(每个20MB)的子目录(即Areas\Administration\Views)中设置了maxRequestLength和maxAllowedContentLength。我在administration中进行了文件上载,当我尝试上载一个大文件(在本例中为9MB)时,我会得到“超过最大请求长度”。如果我将这两个设置移动到根目录,它会工作,但我不希望这样做。有什么建议吗 技术:Windows Server 2008 Enterprise上的ASP.NET、.NET 4.0、

我在web.config(每个20MB)的子目录(即Areas\Administration\Views)中设置了maxRequestLength和maxAllowedContentLength。我在administration中进行了文件上载,当我尝试上载一个大文件(在本例中为9MB)时,我会得到“超过最大请求长度”。如果我将这两个设置移动到根目录,它会工作,但我不希望这样做。有什么建议吗

技术:Windows Server 2008 Enterprise上的ASP.NET、.NET 4.0、MVC 3和IIS 7

堆栈跟踪:

[HttpException (0x80004005): Maximum request length exceeded.]
    System.Web.HttpRequest.GetEntireRawContent() +11472119
    System.Web.HttpRequest.GetMultipartContent() +232
    System.Web.HttpRequest.FillInFormCollection() +345
    System.Web.HttpRequest.get_Form() +157
    Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__e() +63
    Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__11() +20
    Microsoft.Web.Infrastructure.DynamicValidationHelper.DeferredCountArrayList.get_Count() +20
    System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +34
    System.Web.HttpRequest.get_Form() +212
    System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase request) +160
    System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +55
    System.Linq.Enumerable.All(IEnumerable`1 source, Func`2 predicate) +149
    System.Web.Mvc.ActionMethodSelector.RunSelectionFilters(ControllerContext controllerContext, List`1 methodInfos) +428
    System.Web.Mvc.ReflectedControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +140
    System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +27
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +148
    System.Web.Mvc.Controller.ExecuteCore() +159
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
[HttpException(0x80004005):超出最大请求长度。]
System.Web.HttpRequest.GetEntireRawContent()+11472119
System.Web.HttpRequest.GetMultipartContent()+232
System.Web.HttpRequest.FillInFormCollection()+345
System.Web.HttpRequest.get_Form()+157
Microsoft.Web.Infrastructure.DynamicValidationHelper.c_uDisplayClass12.b_ue()+63
Microsoft.Web.Infrastructure.DynamicValidationHelper.c_uuDisplayClass12.b_uuu11()+20
Microsoft.Web.Infrastructure.DynamicValidationHelper.DeferredCountArrayList.get_Count()+20
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc,RequestValidationSource requestCollection)+34
System.Web.HttpRequest.get_Form()+212
System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase请求)+160
System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext ControllerContext,MethodInfo MethodInfo)+55
System.Linq.Enumerable.All(IEnumerable`1源,Func`2谓词)+149
System.Web.Mvc.ActionMethodSelector.RunSelectionFilters(ControllerContext ControllerContext,List`1 methodInfos)+428
System.Web.Mvc.ReflectedControllerDescriptor.FindAction(ControllerContext ControllerContext,String actionName)+140
System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext ControllerContext,ControllerDescriptor ControllerDescriptor,String actionName)+27
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext ControllerContext,String actionName)+148
System.Web.Mvc.Controller.ExecuteCore()+159
System.Web.Mvc.ControllerBase.Execute(RequestContext)+335
System.Web.Mvc.c__显示类b.b__5()+62
System.Web.Mvc.Async.c__显示类1.b__0()+20
System.Web.Mvc.c_uuudisplayClasse.b_uuud()+54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+469
System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值&同步完成)+375

在您的webconfig文件中,您需要用以下方式声明带有路径的标记:

<location path="controller/action">
  <system.web>
    <!-- maxRequestLength is in kilobytes (KB)  -->
    <httpRuntime maxRequestLength="5120" /> <!-- 5MB -->
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <!-- maxAllowedContentLength is in bytes (B)  -->
        <requestLimits maxAllowedContentLength="5242880"/> <!-- 5MB -->
      </requestFiltering>
    </security>
  </system.webServer>
</location>


如果我的答案对您有帮助,请接受我的答案。否则,请发表评论,告诉我们有关您的问题的更多信息。您的意思是,如果我有一个名为
VideoController
的控制器和一个名为
Save
的操作,那么我必须将路径设置为
path=“Video/Save”
?我说的是ASP.NETWebAPI。不确定WebAPI路径。这个解决方案是针对MVC的。也许你可以试试“api/控制器/动作”之类的东西?