1. Use the solution with httpcontext. Current empty on the WCF Server:
1) Add the description [aspnetcompatibilityrequirements (requirementsmode = aspnetcompatibilityrequirementsmode. Allowed)] to the server-side WCF class.
2) Add <servicehostingenvironment aspnetcompatibilityenabled = "true"/> to the <system. servicemodel> node of webconfig on the server.
2. Use httpcontext. Current. server. mappath as an alternative solution on the WCF Server:
System. Web. Hosting. hostingenvironment. mappath ("~ /Upload "+ filefolder );
3. Solve the Problem of large file byte [] transmission:
In the server and web. config files, the bindings section is empty, and the service does not specify the bindingconfiguration attribute. Therefore, they use the default 65535 size.
It is easier to locate the problem:
Add a new binding setting (in the system. servicemodel node) in the bindings section to specify the maximum accept data:
< Bindings > < Basichttpbinding > < Binding Name = " Largedata " Maxcompute edmessagesize = " 2147483647 " Messageencoding = " Text "
Transfermode = " Streamed " Sendtimeout = " 00:10:00 " /> </ Basichttpbinding > </ Bindings >
Then, specify the bindingconfiguration attribute for the corresponding service:
< Service Behaviorconfiguration = " Server. Service. wcfservicebehavior " Name = " Server. Service. wcfservice " > < Endpoint Address = "" Binding = " Basichttpbinding " Bindingconfiguration = " Largedata "
Contract = " Server. Service. wcfservice " /> < Endpoint Address = " MEX " Binding = " Mexico httpbinding " Contract = " Imetadataexchange "/> </ Service >
In this way, you can send large enough data from the client.
P.s .:
. By default, only files of 4 MB can be uploaded. Therefore, although the configuration at both ends of the WCF is set, the file cannot be uploaded.. add
<Httpruntimemaxrequestlength="102400"/>
The unit here is kb, so that MB of files can be uploaded. Of course, it is better to perform multipart transmission for such a large file.
4. solutions with the following errors:
① The message cannot be processed. This is probably because the "messages" operation.
Solution: Modify the following nodes in the binding node of the client and server:< Security Mode = "None"> </Security>
② Timeout
Solution: The sendtimeout = "00:05:00" in the <binding name = "wshttpbinding_iservice" node of the client is the timeout time. Just adjust it.