Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 22, 2013 08:02 PM by wyx2000
Contributor
3388 Points
873 Posts
Feb 21, 2013 08:32 PM|LINK
Implemented a MediaTypeFormatter, but no response on call, it does execute the following method, any idea?
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
{
return Task.Factory.StartNew(() => { using (StreamWriter streamWriter = new StreamWriter(writeStream, new UTF8Encoding(false, true))) { streamWriter.Write("<error>?</error>"); } }); }
Participant
1460 Points
285 Posts
Microsoft
Feb 22, 2013 04:57 PM|LINK
Is this method being at all?...if it is and if you are seeing any response, i believe its probably because you are closing the writeStream...do no close the stream as the underlying layer would that for you...
Feb 22, 2013 06:15 PM|LINK
I don't quite get what you are saying. All my code is there, you can tell I don't close the stream.
After upgrade to .NET.Formatting 4.1.0.0, all those write out don't work now.
Feb 22, 2013 06:30 PM|LINK
wyx2000 All my code is there, you can tell I don't close the stream.
i mean the 'using' statement will case the underlying stream to be closed.
using (StreamWriter streamWriter = new StreamWriter(writeStream, new UTF8Encoding(false, true))) { streamWriter.Write("<error>?</error>"); }
Feb 22, 2013 08:02 PM|LINK
Ah, I see, that can explain the problem well.
So that is a break change I think.
Thanks
wyx2000
Contributor
3388 Points
873 Posts
OnWriteToStreamAsync or WriteToStreamAsync?
Feb 21, 2013 08:32 PM|LINK
Implemented a MediaTypeFormatter, but no response on call, it does execute the following method, any idea?
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
{
return Task.Factory.StartNew(() =>
{
using (StreamWriter streamWriter = new StreamWriter(writeStream, new UTF8Encoding(false, true)))
{
streamWriter.Write("<error>?</error>");
}
});
}
Kiran Challa
Participant
1460 Points
285 Posts
Microsoft
Re: OnWriteToStreamAsync or WriteToStreamAsync?
Feb 22, 2013 04:57 PM|LINK
Is this method being at all?...if it is and if you are seeing any response, i believe its probably because you are closing the writeStream...do no close the stream as the underlying layer would that for you...
Kiran Challa
wyx2000
Contributor
3388 Points
873 Posts
Re: OnWriteToStreamAsync or WriteToStreamAsync?
Feb 22, 2013 06:15 PM|LINK
I don't quite get what you are saying. All my code is there, you can tell I don't close the stream.
After upgrade to .NET.Formatting 4.1.0.0, all those write out don't work now.
Kiran Challa
Participant
1460 Points
285 Posts
Microsoft
Re: OnWriteToStreamAsync or WriteToStreamAsync?
Feb 22, 2013 06:30 PM|LINK
i mean the 'using' statement will case the underlying stream to be closed.
using (StreamWriter streamWriter = new StreamWriter(writeStream, new UTF8Encoding(false, true)))
{
streamWriter.Write("<error>?</error>");
}
Kiran Challa
wyx2000
Contributor
3388 Points
873 Posts
Re: OnWriteToStreamAsync or WriteToStreamAsync?
Feb 22, 2013 08:02 PM|LINK
Ah, I see, that can explain the problem well.
So that is a break change I think.
Thanks