我正在使用启用了ajax的wcf服务和一个jquery POST方法,该方法为我的侧边栏菜单获取数据。
它在页面加载后工作得很好但是如果我等待几分钟然后尝试获取数据我得不到任何响应。 Firebug显示请求是从浏览器发送的,但是在调试模式下我没有看到命中,服务器甚至没有意识到发送了请求。
有什么建议吗?
修改
这里有一些相关的代码
客户机侧:
$.ajaxSetup({
type: "POST",
contentType: "application/json",
timeout: 10000,
cache:false,
dataType: "json"
});
function getSubcategories(categoryId, onSuccess, onError) {
var request = new Object();
request.categoryId = categoryId;
var jsonData = JSON.stringify(request);
$.ajax({
url: "/SiteService.svc/GetSubcategories",
data: jsonData,
success: onSuccess,
error: onError
});
服务器端:
[ServiceContract(Namespace = "myService")]
public interface ISiteService
{
[OperationContract()]
SiteServCategory[] GetSubcategories(int categoryId);
}
web.confing
<system.serviceModel>
<services>
<service name="App_Code.Services.Website.Site.SiteService" behaviorConfiguration="DebugEnabled">
<endpoint behaviorConfiguration="SiteServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="App_Code.Services.Website.Site.ISiteService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="SiteServiceAspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DebugEnabled">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>