Windows Server 2008 R2,WCF服务上载不适用于HTTPS [英] Windows Server 2008 R2 , WCF service Uploading not working for HTTPS
问题描述
大家好,
我在Windows Server 2008 R2上安装了IIS,并托管了一个wcf服务。
我创建了自签名证书并使用安全的http连接来访问服务。
我正在使用服务将图像从移动设备上传到服务器。
小尺寸图像上传到服务器(图像大小<1000KB),大小超过1MB限制服务调用是通过错误。
这是一种服务电话方式:
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);
}
总是大文件大小我收到xhr.onerror()错误消息。
这里可能出现什么问题?
我也尝试过使用HTTP服务的HTTP服务图像上传到服务器,那么还需要为HTTPS做任何额外设置吗?
这是来自Wcf服务的配置文件:
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>
提前感谢您的建议。
--Avinash
Thanks in advance for your suggestions.
--Avinash
推荐答案
您需要根据您的要求增加上传文件大小限制。并且它适用于web.config中的更改
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 [ ^ ]
也可以像
WCF流媒体:通过HTTP上传/下载文件 [ ^ ]
这篇关于Windows Server 2008 R2,WCF服务上载不适用于HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!