asp.net-mvc 如何在 asp.net MVC 3 的配置中增加 maxUrlLength 属性?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8245843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 01:36:24  来源:igfitidea点击:

How do I increase the maxUrlLength property in the config in asp.net MVC 3?

asp.net-mvc

提问by NibblyPig

I am getting this error:

我收到此错误:

The length of the URL for this request exceeds the configured maxUrlLength value.

此请求的 URL 长度超过了配置的 maxUrlLength 值。

Looking around the closest thing I can find is in the web.config,

环顾四周,我能找到的最接近的东西是在 web.config 中,

<requestFiltering>
   <requestLimits maxUrl="xxx">
</requestFiltering>

However this is not MaxUrlLength nor does it resolve the issue. Any ideas how to fix?

然而,这不是 MaxUrlLength 也不能解决问题。任何想法如何解决?

回答by Jesse

As per Ashok's answer that would equate to:

根据 Ashok 的回答,这相当于:

<httpRuntime maxUrlLength="1024" relaxedUrlToFileSystemMapping="true"/>

within <system.web>section of the web.config.

<system.web>web.config 的部分内。

回答by Hector Correa

Take a look at this post by Hanselman. Although this post is about accepting typically invalid characters in the URL he also mentions how to configure the length of the path and the query string

看看Hanselman 的这篇文章。虽然这篇文章是关于接受 URL 中通常无效的字符,但他也提到了如何配置路径的长度和查询字符串

While we're in here, note that in ASP.NET 4 you can also change allowed path and queryString lengths:

<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />

当我们在这里时,请注意,在 ASP.NET 4 中,您还可以更改允许的路径和 queryString 长度:

<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />

回答by Van

I had this problem in a rest service I created using C# .net 4. I set the maxUrlLength variable, in the system.web section, of the Web.Config file.

我在使用 C# .net 4 创建的休息服务中遇到了这个问题。我在 Web.Config 文件的 system.web 部分设置了 maxUrlLength 变量。

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxUrlLength="2000"/>
  </system.web>
....

回答by Ashok Padmanabhan

have you seen this msdn articlethat seems to what you need

您是否看过这篇似乎符合您需要的msdn 文章

回答by user3594326

Having the same problem in IIS8, the solution was to modify the root Web.config for the .NET Framework. This file is located in %windir%\Microsoft.NET\Framework\framework_version\CONFIG. Editing the web.config file in the site root did not resolve the issue.

在 IIS8 中遇到同样的问题,解决方案是修改 .NET Framework 的根 Web.config。此文件位于 %windir%\Microsoft.NET\Framework\framework_version\CONFIG。在站点根目录中编辑 web.config 文件没有解决问题。

回答by Marcel

In my case, I edited the setting visually in the IIS application (Request Filtering area):

就我而言,我在 IIS 应用程序(请求过滤区域)中直观地编辑了设置:

request filtering url length

请求过滤url长度

This action modified my web.config as follows:

此操作修改了我的 web.config 如下:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="524288000" maxQueryString="4096" />
  </requestFiltering>
</security>

As was mentioned in some of the other answers, be sure to also consider long query strings in the request.

正如在其他一些答案中提到的,一定要考虑请求中的长查询字符串。