WCF URL 长度导致 IIS 400 错误请求错误 [英] WCF URL Length Causing IIS 400 Bad Request Error

查看:23
本文介绍了WCF URL 长度导致 IIS 400 错误请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 wcf webHttp 端点,今天注意到当使用长 url ~364 个总字符(http://等)调用 httpGet 时,IIS 抛出 400 bad request 错误.在代码中抛出断点永远不会到达.如果我删除了一些参数并有一个 354 的 url,那么 Web 服务将按预期运行.

I have a wcf webHttp endpoint and noticed today that when called httpGet with a long url ~364 total characters (http:// etc counted) IIS throws a 400 bad request error. Throwing a breakpoint in the code never gets reached. If I remove some parameters and have a url that is 354 the web service runs as expected.

我不确定问题出在哪里,因为 url 可能像 2k.我没有发布任何数据,所以我认为我没有达到 4mb 的限制,例如 这里

I'm not sure where the issue is since urls can be like 2k. I'm not posting any data so I don't think I'm hitting a 4mb limit like from here

什么给了?

这里有一些 wcf xml 的东西.

Here's some wcf xml stuff.

    <behaviors>
        <endpointBehaviors>
            <behavior name="REST">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>

<endpoint address="" behaviorConfiguration="REST" binding="customBinding" bindingConfiguration="jsonpBinding" contract="Interface"/>


<bindings>
        <customBinding>
            <binding name="jsonpBinding">
                <jsonpMessageEncoding/>
                <httpTransport manualAddressing="true"/>
            </binding>
        </customBinding>
    </bindings>
    <extensions>
        <bindingElementExtensions>
            <add name="jsonpMessageEncoding" type="Microsoft.Ajax.Samples.JsonpBindingExtension, service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
        </bindingElementExtensions>
    </extensions>

我刚刚删除了显着减小 url 大小的回调函数名称,但它仍然抛出 400 错误.这让我觉得可以作为字符串参数发送的文本有 WCF 大小限制.

I just removed the callback function name which significantly reduced the size of the url and it still threw a 400 error. This makes me think that there is a WCF size limit on the text that can be sent in as a string parameter.

这里;是一些合同的东西

here;'s some Contract stuff

    [OperationContract]
[WebGet(UriTemplate = @"{userName}/layer({layerName})returnAttributes({attributeList})where({attributeName})({op})({attributeValue})", ResponseFormat = WebMessageFormat.Json)]
[JSONPBehavior(callback = "callback")]
DojoGrouping GetAttributes(string userName, string layerName, string attributeList, string attributeName, string attributeValue);

问题在于属性列表,它可以是逗号分隔的列表.

the issue is with attributeList which can be comma separated list.

所以像这样的 url 调用

so with a url call like

http://../demo/layer(OfficialsLookup)returnAttributes(USHOUSE,US_Photo,US_Web,US_Name,SENDIST,SEN_Name,SEN_Email,SEN_Party,SEN_Photo,REPDIST,REP_Name,REP_Email,REP_Party,REP_Web,REP_Photo)utmX(430)utmY(4502)

它破产了.但是,如果我缩短返回属性文本,那么它会正常运行.

it busts. But if i shorten the return attribute text then it functions properly.

I've added I added the following entry into the registry: 
Key Name: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesHTTPParameters 
Class Name: <NO CLASS> 
Last Write Time: 1/25/2011 - 3:34 PM 
Value 0 
Name: UrlSegmentMaxLength 
Type: REG_DWORD 
Data: 0x200 

添加后我重新启动了机器,但仍然收到相同的错误.这是修改 WCF 和 IIS 正在使用的 HTTP.sys 设置的正确位置吗?有没有办法测试 WCF 是否受到此注册表值的影响?

I rebooted the machine after adding it and am still receiving the same error. Is this the correct spot to be modifying the HTTP.sys settings that WCF and IIS are using? Is there a way to test that WCF is being affected by this registry value?

这是一个相关的帖子,没有答案,但说 httpsys 的东西没有修复我们正在使用的 64 位服务器.

Here is a related post with no answer but saying that the httpsys stuff did not fix a 64 bit server which is what we are using.

相关帖子

推荐答案

为了解决我们的问题,我们必须使用 .NET 4.0 框架.我们将 Web 服务移动到在 .net 4.0 应用程序池下运行,并将目标框架更改为 4.0.这导致网站吐出 url is too long 错误而不仅仅是一个错误的请求.在中添加网络配置条目后

To fix our issue we had to use the .NET 4.0 framework. We moved the web service to run under a .net 4.0 app pool and changed the target framework to 4.0. This caused the site to spit out url is too long error instead of just a bad request. After adding a web config entry in

<system.web>

添加

<httpRuntime maxUrlLength="500" />

对于最大 url 长度,服务已按预期启动并运行.

for max url length, the service is up and running as expected.

这篇关于WCF URL 长度导致 IIS 400 错误请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆