IIS7上的jsonp查询长度限制 [英] jsonp query length limitation on IIS7
问题描述
我正在尝试使用jsonp在不同的域中传递数据。
调用我服务的代码
I am trying to pass data across different domain using jsonp.
Code to call my service
$.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
First i hosted this service on IIS6 and passed data up to length of 3000 and it worked fine,now i moved my service to IIS7 .The service work properly on IIS7 even even but it does not allow me to pass 3000 characters at a time instead the url length is limited to 2000 now. Do i have to make any additional settings for IIS7
Below is my 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>
推荐答案
.ajax({
type: GET,
url: window .serviceURL + CheckWebsite,
data:{
domain:domainName,
website:sitename
},
dataType: jsonp,
contentType: 应用/ JSON; charset = utf-8,
成功:功能(数据){},
错误: function (jqXHR,textStatus,errorThrown){
if ( window 。 console ) console .log( 错误... + textStatus + + errorThrown);
}
});
.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
First i hosted this service on IIS6 and passed data up to length of 3000 and it worked fine,now i moved my service to IIS7 .The service work properly on IIS7 even even but it does not allow me to pass 3000 characters at a time instead the url length is limited to 2000 now. Do i have to make any additional settings for IIS7
Below is my 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>
你可以通过增加maxJsonLength
来增加查询的大小。
请尝试将以下代码添加到web.config文件中。如果您需要任何帮助,请发送邮件
you can increase the size of the query by incresing themaxJsonLength
.
Please try adding following code to the web.config file. if you need any help please send a message
<configuration>
<system.web.extensions>
<scripting>
<webservices>
<jsonserialization maxjsonlength="102400" />
</webservices>
</scripting>
</system.web.extensions>
</configuration>
您可能还想阅读以下文章
http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=9709891 [ ^ ]
这篇关于IIS7上的jsonp查询长度限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!