c# - .Net WebAPI not responding when returning HttpResponseMessage -
i'm having problem web api action when returning httpresponsemessage
. object return stream of audio, file have 60kb , in first time have success when call web api, however, in next time web api not responds , browser stay loading.
below following code:
why web api not works/responds in next time call?
[httpget] [route("api/card/playaudio/{text}")] public async task<httpresponsemessage> playaudio(string text) { var audiostream = await _cardservice.getstream(text); return createaudioresponse(audiostream); } private httpresponsemessage createaudioresponse(system.io.stream audiostream) { var result = this.request.createresponse(httpstatuscode.ok); //httpresponsemessage result = new httpresponsemessage(httpstatuscode.ok); result.content = new streamcontent(audiostream); result.content.headers.contentdisposition = new contentdispositionheadervalue("attachment"); result.content.headers.contentdisposition.filename = string.format("{0}.mp3", new guid().tostring()); result.content.headers.contenttype = new mediatypeheadervalue("application/octet-stream"); result.content.headers.contentlength = audiostream.length; return result; }
Comments
Post a Comment