I’m using an ajax enabled wcf service with a jquery POST method which gets data for my sidebar menus.
It works great just after the page loads but if i wait a few minutes and then try to get the data i get no response. Firebug shows the request is sent from the browser however i’m not seeing a hit while in debug mode, the server doesn’t even realize a request was sent.
any suggestions?
EDIT
here is some relevant code
clientSide:
$.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
});
ServerSide:
[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>
I believe your OperationContract needs to be decorated with either the WebInvoke or WebGet for it to be exposed as JSON.
[WebInvoke(BodyStyle=WebMessageBodyStyle.Bare, ResponseFormat=WebMessageFormat.Json)]