【问题标题】:look like Query string parameter length issue in my MVC website看起来像我的 MVC 网站中的查询字符串参数长度问题
【发布时间】:2015-10-16 00:53:24
【问题描述】:

谁能告诉我我的网址有问题:- http://www.advantarealty.net/Search//Condo,Single-Family-Home,Townhome_PropertyType/True_ForMap/8_Zoom/-81.3043212890625T29.099376992628493,-80.88134765625T28.9120147012556,-80.826416015625T28.41555985166584,-81.1669921875T28.033197847676377,-81.6888427734375T28.033197847676377,-82.1392822265625T28.222130007158537,-82.2601318359375T28.584521719370418,-82.1612548828125T28.92163128242129,-81.9305419921875T29.257648503615542,-81.6339111328125T29.248063243796576,-81.6064453125T28.849485201023,-81.3043212890625T29.099376992628493_Polygon/

我总是遇到错误。

错误请求 - 无效的 URL。 HTTP 错误 400。请求 URL 无效。

/Search/ 之后的所有内容都是我通过路由处理的查询字符串。

 routes.MapRoute(
    "Search", // Route name
    "Search/{*q}", // URL with parameters
    new { controller = "Search", action = "Index", q = UrlParameter.Optional } // Parameter defaults
);

在上面的 URL 中,我猜它超过了最大查询字符串参数长度,所以我尝试像下面这样增加它。

<system.web>
    <!--<httpRuntime maxQueryStringLength="32768" maxUrlLength="65536"/>-->
    <httpRuntime targetFramework="4.5" maxUrlLength="2097151" relaxedUrlToFileSystemMapping="true" maxQueryStringLength="2097151" />
</system.web>
<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxUrl="40960" maxQueryString="2097151" />
      </requestFiltering>
    </security>
  </system.webServer>

我试过了 request exceeds the configured maxQueryStringLength when using [Authorize]

How to configure the web.config to allow requests of any length

【问题讨论】:

    标签: asp.net asp.net-mvc url iis windows-server-2008-r2


    【解决方案1】:

    检查路线模式。我认为 '/' 破坏了 url 并且与定义的路由不匹配。

    【讨论】:

    • 我已经使用路由处理了。让我将其添加到问题本身中。
    • 比其他'/'用来做什么?我认为您需要在发送到该方法之前对您的查询字符串进行编码。由于 '/' 是特殊字符,它会破坏 url 并且路由与定义的参数不匹配。
    • / 用于进一步分解查询字符串以获取搜索条件。虽然它工作正常
    • 如果我从 url 中删除一些数据,你可以看到它工作。 advantarealty.net/Search//True_ForMap/8_Zoom/…
    猜你喜欢
    • 2014-01-14
    • 2015-10-15
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-10
    相关资源
    最近更新 更多