Click here to Skip to main content
14,456,059 members
Rate this:
Please Sign up or sign in to vote.
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') ;
       xhr.send(jsonText);
   }


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 :
<system.serviceModel>
    <bindings>
      <webHttpBinding>
        <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"/>
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="ServiceBehaviour" name="Service">
        <endpoint address="" behaviorConfiguration="EndpBehaviour" binding="webHttpBinding" bindingConfiguration="webHttpBindingClient" name="webHttpEndPointBinding" contract="IService"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">          
          <serviceMetadata httpsGetEnabled="true"/>          
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="EndpBehaviour">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint crossDomainScriptAccessEnabled="true"/>
      </webHttpEndpoint>
      <webScriptEndpoint>
        <standardEndpoint crossDomainScriptAccessEnabled="true"/>
      </webScriptEndpoint>
    </standardEndpoints>
  </system.serviceModel>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <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"/>
      </customHeaders>
    </httpProtocol>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="20971520" />
      </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>


Thanks in advance for your suggestions.

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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

<system.web>
    <httpruntime maxquerystringlength="2097151" maxurllength="2097151" maxrequestlength="2097151" />
  </system.web>


maxRequestLength [^]


also refer this like
WCF Streaming: Upload/Download Files Over HTTP[^]
   
Comments
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100