asp.net - ASP.NET MVC 中的 URL 长度 - 超过 260 个字符会导致错误请求 - 无效的 URL

标签 asp.net asp.net-mvc asp.net-mvc-4 url azure

我遇到了 URL 超过 260 个字符的问题

  • ASP.NET MVC 4.0
  • Umbraco CMS
  • Azure 网站

IIS 阻塞并引发以下错误:

Bad Request - Invalid URL

HTTP Error 400. The request URL is invalid.

Example URL:

http://example.com/article/123/some-headline-longer-than-260-characters-with-only-text-and-numbers-used

在我的例子中,URL 的长度为 303 个字符,没有任何查询字符串。将 URL 缩短为 260 个字符可以解决问题,但对我来说这不是一个可行的解决方案。由于我使用的是 ASP.NET,所以我将以下内容添加到 web.config - 但是,即使使用 maxUrlLength="1024",问题仍然存在:

<?xml version="1.0"?>
   <configuration>
      <system.web>
         <httpRuntime 
              requestValidationMode="4.0" 
              requestPathInvalidCharacters="&lt;,&gt;"
              maxUrlLength="1024" 
              maxQueryStringLength="768" 
              relaxedUrlToFileSystemMapping="true" />
      </system.web>
   </configuration>

附加信息:我的所有网址均保持在 2000 左右的限制以下(参见 What is the maximum length of a URL in different browsers? )

有什么想法吗?

最佳答案

您可能需要扩展注册表中的限制:http://support.microsoft.com/kb/820129

关于asp.net - ASP.NET MVC 中的 URL 长度 - 超过 260 个字符会导致错误请求 - 无效的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27870604/

相关文章:

html - 如何解决html中固定列的无限垂直滚动问题

javascript - Jquery调用时获取对象Object错误

javascript - 如何让div中的图片从右向左显示

asp.net - 如何 trim ClientValidationFunction 中的字符串

javascript - 如何禁用和启用 Div 的所有内容

javascript - 使用 ASP.NET MVC 5 应用程序设置 ReactJS

c# - 在 Visual Studio 中启用 TagHelper Intellisense 支持

asp.net - 无法让我的导航栏以网站 ASP.Net 为中心

asp.net - 发布到 Azure 失败,出现 500 内部服务器错误

asp.net-mvc - 从 Controller 中的强类型 View 获取数据