Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi All,

I had installed an IIS on Windows server 2008 R2 , and hosted an wcf service.
I had created a self signed certificate and using a secure http connection to access service.
I am using service to upload images from mobile devices to server.
The small size image is uploading to server (image size < 1000KB) , it the size exceeds 1MB limit the service call is through an error.
Here is a service call method :

jsonText = JSON.stringify({"ImageData":ImageData});

    var url = getURL()+"UplodImage";

    var xhr = createCORSRequest('POST', url);
   if (!xhr) {
         alert('CORS not supported');

   xhr.onload = function () {
           var data = JSON.parse(xhr.responseText);

   xhr.onerror = function() {
           alert('Woops, there was an error making the request.');
       xhr.setRequestHeader('Content-Type', 'application/json') ;

Always for large file size I am getting an "xhr.onerror()" error message.

What may be the issue here?

I had also tried with HTTP service, with HTTP service images were uploading to server, So it there any extra settings required to do for HTTPS ?

Here is configuration file from Wcf service :
        <binding name="webHttpBindingClient" closeTimeout="00:50:00" openTimeout="00:50:00" receiveTimeout="00:50:50" sendTimeout="00:50:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered" useDefaultWebProxy="true" crossDomainScriptAccessEnabled="true">
          <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
          <security mode="Transport"/>
      <service behaviorConfiguration="ServiceBehaviour" name="Service">
        <endpoint address="" behaviorConfiguration="EndpBehaviour" binding="webHttpBinding" bindingConfiguration="webHttpBindingClient" name="webHttpEndPointBinding" contract="IService"/>
        <behavior name="ServiceBehaviour">          
          <serviceMetadata httpsGetEnabled="true"/>          
          <serviceDebug includeExceptionDetailInFaults="true"/>
        <behavior name="EndpBehaviour">
          <webHttp helpEnabled="true"/>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        <standardEndpoint crossDomainScriptAccessEnabled="true"/>
        <standardEndpoint crossDomainScriptAccessEnabled="true"/>
        <add name="Access-Control-Allow-Origin" value="*"/>
        <add name="Access-Control-Allow-Credentials" value="true"/>
        <add name="Access-Control-Allow-Methods" value="POST, GET,OPTIONS"/>
        <add name="Access-Control-Max-Age" value="600000"/>
        <add name="Access-Control-Allow-Headers" value="content-type,Accept"/>
        <add name="Content-Type" value="application/json;charset=UTF-8"/>
        <add name="Allow" value="OPTIONS, TRACE, GET, HEAD, POST"/>
        <requestLimits maxAllowedContentLength="20971520" />
    <modules runAllManagedModulesForAllRequests="true"/>

Thanks in advance for your suggestions.

Updated 17-Dec-13 18:06pm
Avinash6474 18-Dec-13 0:38am    
Is SSL certificate is having any file size limit, which is causing an issue?

1 solution

you need to increase upload file size limit as per your requirement. and its realted to changes in web.config

    <httpruntime maxquerystringlength="2097151" maxurllength="2097151" maxrequestlength="2097151" />

maxRequestLength [^]

also refer this like
WCF Streaming: Upload/Download Files Over HTTP[^]
Share this answer
Avinash6474 18-Dec-13 5:50am    
Thank you so much :) , Its working fine now.
Tejas Vaishnav 18-Dec-13 23:52pm    
Great to here, your problem is solved now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900