我正在尝试使用 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 个字符url 长度现在限制为 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>