I am facing an issue with the WCF service for ASP.NET AJAX. I have written one static calss to maintain the state at the WCF side and testing the same from javaScript. The following steps are what I am doing;
in $(document).ready(),
- Check for the "CurrentUser" object in the state
- If return value is NULL, then get the user with given ID and put it into State.
- Reload the page or move tho another page. This is to test the state duting page reload or moveing to another page.
Now the symptom is, I am calling a method (GetFromState()) to get a value form the state. This works in alternative cycles. Means, for the first time page load it work, second page it won't and for the third time it works.
The exception is;
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter ProjectDocs:pStateKey. The InnerException message was 'There was an error deserializing the object of type System.String. The token ':' was expected but found ','.'. Please see InnerException for more details.**
of type System.ServiceModel.Dispatcher.NetDispatcherFaultException.
I used WCF loging by enabling it in web.config and retrieved the message that i am passing. The message is as follows;
<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<Cache-Control>no-cache</Cache-Control>
<Connection>Keep-Alive</Connection>
<Content-Length>73</Content-Length>
<Content-Type>application/json; charset=utf-8</Content-Type>
<Accept>*/*</Accept>
<Accept-Encoding>gzip, deflate</Accept-Encoding>
<Accept-Language>en-us</Accept-Language>
<Cookie>ASP.NET_SessionId=gg53gxmy3pkqrabtr0czvnsx</Cookie>
<Host>localhost:1496</Host>
<Referer>http://localhost:1496/Admin/RoleManagement.aspx</Referer>
<User-Agent>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; BOIE9;ENIN)</User-Agent>
<x-requested-with>XMLHttpRequest</x-requested-with>
</WebHeaders>
</HttpRequest>
<root type="object" xmlns="">
<pStateKey type="string">0c354a4f-cdaa-08cd-8c86-c1e06bec6b8d</pStateKey>
<pKey type="string">CurrentUser</pKey>
</root>
</MessageLogTraceRecord>
The javaScript code that i am using is as follows;
$(document).ready(function () {
var stateKey = GetStateKey();
ProjectDocs.StateActions.GetFromState(stateKey.trim(), 'CurrentUser', function (result, e) {
if (result != null && result.Code != null && result.Code != '') {
$get('<%=CurrentUser.ClientID %>').value = result;
}
else {//Redirect to login page
//For time being
var curUser = ProjectDocs.UserActions.GetUserDetails('31534974-c759-08cd-5e8b-8dd0045a6b25', function (result, e) {
$get('<%=CurrentUser.ClientID %>').value = result;
AddToState('CurrentUser', result);
alert(result.Code);
}, function (result, e) { N_NotifyMessage('Unable to get user details.', result.get_message(), 2); });
开发者_如何学C }
}, function (result, e) {
//Redirect ro login page
N_NotifyMessage(GetStateKey(), result.get_message(), 2);
});
});
Finally... Please help me to ressolve this issue.....
Thanks in advance, Pradeep Yamujala
it looks as if the message trace you have put is for a successful call. Do you have another trace for a failed call
精彩评论