代码改变世界

Silverlight :服务器返回错误: NotFound 错误

2010-07-09 15:45  cnb_mtime  阅读(373)  评论(0编辑  收藏  举报

今天用Silverlight+wcf上传文件的时候发现读入的流字节只要大于16384B就会报 server returned an error: NotFound 错误

解决办法是修改web.config文件

注意27到34 行就可以了

 

<?xml version="1.0" encoding="UTF-8"?>
<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <customBinding>
                <binding name="Service.customBinding0">
                    <binaryMessageEncoding />
                    <httpTransport />
                </binding>
                <binding name="UpFileService.customBinding0">
                    <binaryMessageEncoding>
                        <readerQuotas maxArrayLength="2097152"/>
                        <!--2MB-->
                    </binaryMessageEncoding>
                    <httpTransport maxReceivedMessageSize="2147483647"/>
                </binding>
            </customBinding>
        </bindings>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
   multipleSiteBindingsEnabled="true" />
        <services>
            <service name="Service">
                <endpoint address="" binding="customBinding" bindingConfiguration="Service.customBinding0"
                 contract="Service" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
            <service name="UpFileService">
                <endpoint address="" binding="customBinding" bindingConfiguration="UpFileService.customBinding0"
                 contract="UpFileService" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>
    <system.webServer>
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>

 

1 <?xml version="1.0" encoding="UTF-8"?>
2  <!--
3 有关如何配置 ASP.NET 应用程序的详细信息,请访问
4 http://go.microsoft.com/fwlink/?LinkId=169433
5 -->
6  <configuration>
7 <system.web>
8 <compilation debug="true" targetFramework="4.0" />
9 </system.web>
10 <system.serviceModel>
11 <behaviors>
12 <serviceBehaviors>
13 <behavior name="">
14 <serviceMetadata httpGetEnabled="true" />
15 <serviceDebug includeExceptionDetailInFaults="false" />
16 <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
17 </behavior>
18 </serviceBehaviors>
19 </behaviors>
20 <bindings>
21 <customBinding>
22 <binding name="Service.customBinding0">
23 <binaryMessageEncoding />
24 <httpTransport />
25 </binding>
26 <binding name="UpFileService.customBinding0">
27 -----------------------------------------------------------------
28 这一部分就是需要修改的部分:注意对应你的文件上传服务
29 <binaryMessageEncoding>
30 <readerQuotas maxArrayLength="2097152"/>
31 <!--2MB-->
32 </binaryMessageEncoding>
33 <httpTransport maxReceivedMessageSize="2147483647"/>
34 -----------------------------------------------------------------
35 </binding>
36 </customBinding>
37 </bindings>
38 <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
39 multipleSiteBindingsEnabled="true" />
40 <services>
41 <service name="Service">
42 <endpoint address="" binding="customBinding" bindingConfiguration="Service.customBinding0"
43 contract="Service" />
44 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
45 </service>
46 <service name="UpFileService">
47 <endpoint address="" binding="customBinding" bindingConfiguration="UpFileService.customBinding0"
48 contract="UpFileService" />
49 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
50 </service>
51 </services>
52 </system.serviceModel>
53 <system.webServer>
54 <directoryBrowse enabled="true" />
55 </system.webServer>
56  </configuration>