Click here to Skip to main content
15,881,812 members

Windows Server 2008 R2 , WCF service Uploading not working for HTTPS

Avinash6474 asked:

Open original thread
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 :

JavaScript
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 :
C#
<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
Tags: Javascript, HTML, Windows, Windows 2008 R2, IIS7.5, WCFServices

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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