我正在尝试使用jsonp在不同的域中传递数据。 拨打我的服务的代码
$.ajax({
type: "GET",
url: window.serviceURL + "CheckWebsite",
data: {
domain: domainName,
website: sitename
},
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
success: function (data) {},
error: function (jqXHR, textStatus, errorThrown) {
if (window.console) console.log("Error... " + textStatus + " " + errorThrown);
}
});
首先我在IIS6上托管了这项服务,并将数据传输到3000长度并且工作正常,现在我将我的服务移至IIS7。该服务在IIS7上正常工作,即使它也不允许我传递3000个字符相反,网址长度现在限制为2000。 我是否必须为IIS7进行任何其他设置
以下是我的web.config
<configuration><system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000" />
</webServices>
</scripting></system.web.extensions><connectionStrings><add name="connectionString" connectionString="Data Source=sql2\\yukon;Initial Catalog=TMS_20110623;User id=sa; password=sa;" /></connectionStrings><appSettings><add key="connectString" value="Data Source=sql4;Initial Catalog=vbr;User id=sa; password=sa;" /></appSettings><system.web><compilation debug="true" targetFramework="4.0" /><httpRuntime enable="true" maxQueryStringLength="50000" maxUrlLength="100000" maxRequestLength="100000" /></system.web><system.serviceModel><standardEndpoints><webScriptEndpoint><standardEndpoint name="" crossDomainScriptAccessEnabled="true" /></webScriptEndpoint><webHttpEndpoint<standardEndpoint name="" helpEnabled="True" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<webHttpBinding>
<binding crossDomainScriptAccessEnabled="true">
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel><system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<defaultDocument>
<files>
<add value="Test1.aspx" />
</files>
</defaultDocument>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol></system.webServer></configuration>