Aliniangole
New Member
I have a sample web application through which i am consuming WCF service, which is intended to upload large capacity[upto 50mb] file to azure storage, I am getting error saying The remote server returned an unexpected response: (413) Request Entity Too Large.This my sample Wcf service code:Interface [IService1.cs]\[code\]namespace FileService{ // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. [ServiceContract] public interface IService1 { [OperationContract] void UploadFile(Stream inputstream); }}\[/code\]Service1.svc\[code\]public class Service1 : IService1 { public void UploadFile(Stream inputstream) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference("images"); // Retrieve reference to a blob named "myblob". CloudBlockBlob blockBlob = container.GetBlockBlobReference("testfile"); blockBlob.UploadFromStream(inputstream); } }\[/code\]Test.aspx page to consume the wcf service\[code\]protected void Button1_Click(object sender, EventArgs e) { ServiceReference1.IService1 clientUpload = new ServiceReference1.Service1Client(); clientUpload.UploadFile(FileUpload1.FileContent); }\[/code\]web.config file in wcf\[code\] <?xml version="1.0"?><configuration> <configSections> </configSections> <!-- To collect diagnostic traces, uncomment the section below or merge with existing system.diagnostics section. To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials. To avoid performance degradation, remember to disable tracing on production deployments. <system.diagnostics> <sharedListeners> <add name="AzureLocalStorage" type="FileService.AzureLocalStorageTraceListener, FileService"/> </sharedListeners> <sources> <source name="System.ServiceModel" switchValue="http://stackoverflow.com/questions/14474636/Verbose, ActivityTracing"> <listeners> <add name="AzureLocalStorage"/> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="http://stackoverflow.com/questions/14474636/Verbose"> <listeners> <add name="AzureLocalStorage"/> </listeners> </source> </sources> </system.diagnostics> --> <system.diagnostics> <trace> <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> <filter type="" /> </add> </listeners> </trace> </system.diagnostics> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IService1" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" > <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> <security mode="None"> </security> </binding> </basicHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <!-- To browse web app root directory during debugging, set the value below to true. Set to false before deployment to avoid disclosing web app folder information. --> <directoryBrowse enabled="true"/> </system.webServer></configuration>\[/code\]web.config File in web application\[code\]<?xml version="1.0"?><!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --><configuration> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0" /> <httpRuntime maxRequestLength="2097150"/> <authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager enabled="false"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IService1" maxReceivedMessageSize="2147483647" /> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:50980/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> </client> </system.serviceModel></configuration>\[/code\]