I have a hosted WCF service in my console application as follow:
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:8080/Test");
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(TestService), baseAddress))
{
// Enable metadata publishing.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("The Test service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close the ServiceHost.
host.Close();
}
}
I have a client in a Windows Store (WinRT) application. I'm getting
"(413) Request Entity Too Large"
when trying to pass a large byte array. How can I set MaxReceivedMessageSize
in my service by code?
If your byte array is too big, then you could always split it to smaller blocks and send those in a loop. You might even want do it in another thread and update progress to the user interface.
You need to create a Binding, and then specify MaxReceivedMessageSize: