2
我目前使用openRasta來構建Rest Api.I在發送Ajax請求時觀察到奇怪的行爲。有時候請求會成功,有時會失敗,並且會給出以下異常。Openrasta數據序列化問題
{Exception:
System.Runtime.Serialization.SerializationException: Expecting element 'root' from namespace ''.. Encountered 'None' with name '', namespace ''.
at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
at OpenRasta.Codecs.JsonDataContractCodec.ReadFrom(IHttpEntity request, IType destinationType, String paramName)
at OpenRasta.OperationModel.Hydrators.RequestEntityReaderHydrator.TryReadPayloadAsObject(IHttpEntity requestEntity, IMediaTypeReader reader, IOperation operation)}
有一件事我觀察到的是,當我保持瀏覽器空閒一段時間說了10多分鐘,我可以看到螢火蟲的請求,但它顯示爲長時間暫停狀態,當它擊中服務器它給以上例外。但是有時候工作得很好。
有人可以解釋我這種行爲嗎?如果我想提供一些額外的代碼相關的。
當我通過visual studio運行並調試它時,我能夠重現此問題。但是,當我使用Rest Client發送相同的請求時,它運行良好。 – prashant 2012-02-20 13:30:20