entity framework - Read timeout error when creating a user c# -
i have strange error appears when creating / editing users. error looks this:
error getting value 'readtimeout' on 'microsoft.owin.host.systemweb.callstreams.inputstream'.
the error in fiddler is:
{ "message": "an error has occurred.", "exceptionmessage": "error getting value 'readtimeout' on 'microsoft.owin.host.systemweb.callstreams.inputstream'.", "exceptiontype": "newtonsoft.json.jsonserializationexception", "stacktrace": " @ newtonsoft.json.serialization.dynamicvalueprovider.getvalue(object target)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.calculatepropertyvalues(jsonwriter writer, object value, jsoncontainercontract contract, jsonproperty member, jsonproperty property, jsoncontract& membercontract, object& membervalue)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializeobject(jsonwriter writer, object value, jsonobjectcontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializedictionary(jsonwriter writer, idictionary values, jsondictionarycontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializeobject(jsonwriter writer, object value, jsonobjectcontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializeobject(jsonwriter writer, object value, jsonobjectcontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializedictionary(jsonwriter writer, idictionary values, jsondictionarycontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializeobject(jsonwriter writer, object value, jsonobjectcontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializeobject(jsonwriter writer, object value, jsonobjectcontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.serialize(jsonwriter jsonwriter, object value, type objecttype)\r\n @ newtonsoft.json.jsonserializer.serializeinternal(jsonwriter jsonwriter, object value, type objecttype)\r\n @ newtonsoft.json.jsonserializer.serialize(jsonwriter jsonwriter, object value)\r\n @ system.net.http.formatting.basejsonmediatypeformatter.writetostream(type type, object value, stream writestream, encoding effectiveencoding)\r\n @ system.net.http.formatting.jsonmediatypeformatter.writetostream(type type, object value, stream writestream, encoding effectiveencoding)\r\n @ system.net.http.formatting.basejsonmediatypeformatter.writetostream(type type, object value, stream writestream, httpcontent content)\r\n @ system.net.http.formatting.basejsonmediatypeformatter.writetostreamasync(type type, object value, stream writestream, httpcontent content, transportcontext transportcontext, cancellationtoken cancellationtoken)\r\n--- end of stack trace previous location exception thrown ---\r\n @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.runtime.compilerservices.taskawaiter.getresult()\r\n @ system.web.http.owin.httpmessagehandleradapter.<bufferresponsecontentasync>d__13.movenext()", "innerexception": { "message": "an error has occurred.", "exceptionmessage": "timeouts not supported on stream.", "exceptiontype": "system.invalidoperationexception", "stacktrace": " @ system.io.stream.get_readtimeout()\r\n @ microsoft.owin.host.systemweb.callstreams.delegatingstream.get_readtimeout()\r\n @ getreadtimeout(object )\r\n @ newtonsoft.json.serialization.dynamicvalueprovider.getvalue(object target)" } }
i have tried figure out causing it, can't find issue. here create function:
/// <summary> /// creates user /// </summary> /// <param name="model">the bound user model</param> /// <returns></returns> [httppost] [route("")] public async task<ihttpactionresult> createuser(userbindingmodel model) { // save our user database return ok(await save(model)); } /// <summary> /// used save user /// </summary> /// <param name="model">the model representing user</param> /// <returns></returns> private async task<ihttpactionresult> save(userbindingmodel model) { // if our modelstate invalid, return bad request if (!modelstate.isvalid) return badrequest(modelstate); // current userid , date var userid = user.identity.getuserid(); var date = datetime.utcnow; // assign our binding model new model var user = new user() { companyid = model.companyid, username = model.email, email = model.email, firstname = model.firstname, lastname = model.lastname, lastlogindate = date, telephone = model.telephone, createdbyid = string.isnullorempty(model.createdbyid) ? userid : model.createdbyid, datecreated = string.isnullorempty(model.createdbyid) ? date : model.datecreated, modifiedbyid = userid, datemodified = date }; // create our result var result = new identityresult(); // if don't have created id if (string.isnullorempty(model.createdbyid)) { // try create user result = await this.userservice.createasync(user); // send our confirmation email await sendconfirmationemail(user.id); } else // else { // try update user result = await this.userservice.updateasync(user); } // if creation fails, return error if (!result.succeeded) return geterrorresult(result); // return result return ok(this.modelfactory.create(user)); } /// <summary> /// used send confirmation email user specified /// </summary> /// <param name="userid">the id of user wish send email to</param> /// <returns></returns> private async task sendconfirmationemail(string userid) { // generate our unique code var code = await this.userservice.generateemailconfirmationtokenasync(userid); // create callback url var callbackurl = new uri(url.link("confirmemailroute", new { userid = userid, code = code }).replace("api/users", "#/account")); // send email await this.userservice.sendemailasync(userid, "confirm account", "please confirm account clicking <a href=\"" + callbackurl + "\">here</a>"); }
has had error before or know causing it? have googled , errors seem tied usermanager strange, no 1 has answers.
this occurs when you're "double wrapping", or nesting, result before returning through web api, exception you're seeing json serialization hitting unsupported property of inner result.
to fix this, review methods returning ihttpactionresult
. i'm confused why included createuser
method in code doesn't appear used save
method, suspected issue. if had called createuser
inside save
method , tried return result of it, you'd double wrapping.
Comments
Post a Comment