I have a wcf service on one side and an mvc website on the client side. I need to download a file from the server which wcf resides to mvc client, then user can download the file from the web application. I have a LinkStream
message contract on wcf. The file represented by the fileInfo
object below contains a 1 gig of data in it.
return new LinkStream { Stream = fileInfo.OpenRead(), Instant = true };
When client makes this call though I check the windows task manager on the server and I am seeing a memory usage peak there, it goes up more than 4gig then falls back to where it was and closes the connection and throws the following exception on client:
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:'<!DOCTYPE html>
<html>
<head>
<title>Overflow or underflow in the arithmetic operation.</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font- size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
@media screen and (max-width: 639p'.
Here are my config files on wcf and mvc side:
WCF:
<system.serviceModel><bindings>
<basicHttpBinding>
<binding name="LinkEndBinding" receiveTimeout="00:05:10" sendTimeout="00:05:30"
transferMode="Streamed" maxBufferSize="65536" maxReceivedMessageSize="1288490188" useDefaultWebProxy="false" >
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Links.Links" >
<endpoint binding="basicHttpBinding" bindingName="LinkEndBinding" contract="Links.ILinks" />
</service>
</services>
</system.serviceModel>
MVC:
<system.serviceModel><bindings>
<basicHttpBinding>
<binding name="LinkEndBinding_ILinks" receiveTimeout="00:05:10" sendTimeout="00:05:30" transferMode="Streamed" maxBufferSize="65536" maxReceivedMessageSize="1288490188" useDefaultWebProxy="false">
<security mode="None" />
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="<myUrl>/Core.Links.Implementation/Links.svc" binding="basicHttpBinding" bindingConfiguration="LinkEndBinding_ILinks" contract="LinkService.ILinks" name="LinkEndBinding_ILinks" />
</client>
</system.serviceModel>
Message Contract:
[MessageContract]public class LinkStream : IDisposable
{
[MessageHeader(MustUnderstand = true)]
public bool Instant { get; set; }
[MessageBodyMember]
public Stream Stream { get; set; }
public void Dispose ()
{
Stream.Close();
}
}
I am really confused here. And open to any suggestions :)