我用一个 HttpHandler 处理.doc 的request.现在我有两台WebServers, Web1 and Web2. Client会向Web1发出request 来取一个 test.doc。但是test.doc位于web2上,Client不可以接触web2,所以必须有web1向web2发出一个httpwebrequest,拿到数据流后再写进 Web1 给 client的response 中. 现在在client的确拿到了test.doc,但是却是一个坏了的test.doc。无法打开。当我将test.doc放在web1本地的一个文件夹中,用FileStream打开这个test.doc,然后写入给 client的response 中,就可以得到正确的结果。不知道问题出在哪,请各位大虾指点,或者提供另外一个解决方案给我。谢谢

解决方案 »

  1.   

    >>>所以必须有web1向web2发出一个httpwebrequesthow did you read out the data? your page on web2 needs to write .doc in binary format, then web1 reads it in binary formatIf you want to use string, on web2, use Convert.ToBase64String, then write back, on web1, use StreamReader to read back a string, then use Convert.FromBase64String to get the binary data, then use Response.BinaryWritesuggestion, between web1/web2, use webservice and pass back byte[], then web1 writes it back with Response.BinaryWrite
      

  2.   

    No I've figured out a solution for my problem. It because I have to use a BinaryReader in Web1 to read the stream back from Web2, then write it into the Response from Web1 to client. Then everything is ok. So far, I still dont undertand why i have to use one BinaryReader to read the stream back from Web2. I just keep try many methods and solve it unexpectantly. It is luck. I am still wondering where any body can tell me why.