在IIS6,邮政数据(方法参数)jQuery中ajax的帖子WCF服务在IE调零了(除非小提琴手正在运行) [英] Under IIS6, Post Data (method arguments) in jquery ajax post to WCF service is nulled out in IE (unless fiddler is running)

查看:155
本文介绍了在IIS6,邮政数据(方法参数)jQuery中ajax的帖子WCF服务在IE调零了(除非小提琴手正在运行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

被敲打一下这个问题有一段时间了。

Been beating about this problem for a while now.

在IIS6和Windows身份验证,每当我试图使用jQuery张贴到一个WCF服务,服务方法被调用和执行,但所有的post数据(方法参数)为null。这似乎只在IE8版本,是该计算机上发生。这不会发生在Firefox中,这也不会发生,奇怪的是,当小提琴手正在运行(作为代理)。

Under IIS6 and windows authentication, whenever I attempt to use jquery to post to a WCF service, the service method is called and executed but all of the post data (the method arguments) are null. This only seems to occur on the IE8 version that is on that machine. This does not occur in Firefox and this also does not occur, strangely enough, when fiddler is running (acting as a proxy).

这code IIS7下工作正常,并出现在IIS6匿名身份验证,以做工精细。

This code works fine under IIS7 and appears to work fine under IIS6 Anonymous Authentication.

POST数据仅仅是JSON。

The post data is just JSON.

$.callService('GetCurrentTemplates', pagingData, GetCurrentTemplateSucceeded, ServiceFailed);

$.callService = function (url, data, successHandler, failHandler) {
    var applicationUrl = $("#hdApplicationUrl").val();
    $.ajax({
        type: "POST", //GET or POST or PUT or DELETE verb
        url: applicationUrl + "Service.svc/" + url, // Location of the service
        data: $.jsonSerialize(data), //Data sent to server
        contentType: "application/json; charset=utf-8", // content type sent to server
        dataType: "json", //Expected data format from server
        processdata: true, //True or False
        success: function (result) {
            if (result == null) {
                var resultObj = new Object();
                resultObj.status = 401;
                resultObj.statusText = 'Unauthorized';
                $.showError(resultObj);
                return;
            }
            if (successHandler != null && successHandler != undefined)
                successHandler(result);
        }, // When success
        error: function (result) {
            $.showError(result);
        } // When Service call fails
    });

WCF服务被设计为使用WebServiceHostFactory和web.config中定义如下:

The WCF service was designed to use the WebServiceHostFactory and web.config definitions are as follows:

<services>
  <service name="Company.Core.TemplateService" behaviorConfiguration="templateWcfBehavior">
    <endpoint address="" binding="webHttpBinding" bindingConfiguration="templateWebHttpBinding" behaviorConfiguration="jsonEndpointBehavior" contract="Company.Core.ITemplateService" />
  </service>
</services>

<behaviors>
    <endpointBehaviors>
        <behavior name="jsonEndpointBehavior">
            <webHttp />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="templateWcfBehavior">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />         
        </behavior>
    </serviceBehaviors>
</behaviors>

<webHttpBinding>
<binding name="templateWebHttpBinding" maxReceivedMessageSize="2147483647">
  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>

服务文件,当然,在匿名访问(而不是Windows身份验证)。

The service file is, of course, under Anonymous Access (not windows authentication).

如果我们的匿名访问运行-everything-,jQuery的传递服务中的相应数据,该方法返回我们希望他们等同样发生,如果我们在集成模式下运行的身份验证,但有小提琴手在客户端上

If we run -everything- under anonymous access, the jquery passes the service the appropriate data, the methods return what we want them to, etc. The same occurs if we run under integrated mode authentication but have fiddler up on the client.

似乎提琴手是变异的数据包来解决一个明显的缺陷 - 有麻烦的问题似乎只出现本地机器(precluding使用的Wireshark /空灵嗅探包,并确定确切的差异)

It seems that Fiddler is mutating the packets to fix an obvious defect - having trouble as the issue only seems to occur local to a machine (precluding the use of wireshark/ethereal to sniff packets and determine the exact differences).

在这一点上,任何意见/信息,您可以提供将是非常有益的。

At this point, any advice / information you can offer would be extremely helpful.

更新2011-09-07:有趣的是,如果我联系服务(和asp.net旋转它) - 然后我可以匿名访问更改服务Windows集成身份验证。虽然服务已经纺和激活,这实际上导致一切都完美运行。如果我等待IIS6刷新配置数据库更改到磁盘,然后运行IISRESET(或回收应用程序池),它失败。失败的原因是由于这项服务的安全设置要求匿名身份验证,但没有为承载此服务的IIS应用程序启用。貌似我左右为难。无论出于何种原因,在匿名访问我的论点后设置都将丢失。如果该服务已经在加速旋转,我可以改变文件集成模式身份验证,一切都将正常工作。如果该服务未纺(或作为应用程序池回收丢失),并将其设置为集成模式authenticatin,我失败,上面提到的错误。叶GADS!

Update 2011-09-07: Interesting enough, if I contact the service (and asp.net spins it up) - I can then change the service from Anonymous Access to Windows Integrated Authentication. While the service is already spun up and activated, this actually causes everything to run perfectly. If I wait for IIS6 to flush the metabase changes to disk and run IISreset (or recycle the app pool), it fails. The reason it fails is due to "Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. ". Looks like I am in a quandary. For whatever reason, under anonymous access my argument post settings are lost. If the service is already spun up, I can change the file to Integrated mode auth and everything will work. If the service is not spun up (or is lost as the app pool recycles) and it is set to integrated mode authenticatin, I fail with the error noted above. Ye Gads!

推荐答案

原因似乎是,一旦遇到IE NTLM,它则需要在网站上的所有其他网页NTLM。请参见 http://support.microsoft.com/?id=251404
你不能发布数据到非NTLM身份验证的网站

Cause appears to be once IE encounters NTLM, it then requires NTLM for all other pages on the site. See http://support.microsoft.com/?id=251404 "You cannot post data to a non-NTLM-authenticated Web site"

建议的解决方法是,如果你启用任何NTLM,一切启用NTLM。

Suggested workaround is if you enable NTLM on anything, enable NTLM on everything.

另一种解决方法就是改变NTLM身份验证过程中客户端注册表黑客。从该链接:

Alternative workaround is a client side registry hacks that change the NTLM auth process. From that link:


  • HKEY_CURRENT_USER /软件/微软/视窗/ CURRENTVERSION / Internet设置/ DisableNTLM preAuth REG_DWORD 1

  • 和开发工具/选项/高级/安全:禁用启用集成Windows身份验证(需要重新启动)

presumably提琴手使得它的工作,因为它是做不同的NTLM握手。

Presumably Fiddler makes it work because it is doing the NTLM handshake differently.

这篇关于在IIS6,邮政数据(方法参数)jQuery中ajax的帖子WCF服务在IE调零了(除非小提琴手正在运行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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