title: Getting Json Output from Byte Array
body: <p>I just started a new project on WCF and to be honest I'm very new at this with limited knowledge. </p>
  
  <p>So what I'm trying to do is open a file that is stored in my computer (e.g. word, pdf, etc.) and display the contents in the webpage in JSon format. I converted the file in a byte array and tried to display the <code>Stream</code>. When I did that it asked me to open the file or save it. I don't want that - I just want the contents of the file to be displayed on my local host when i call the method.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>public string GetRawFile()
      {
          string file = @"C:\.....\TestFile.pdf";
          byte[] rawFile = File.ReadAllBytes(file);
  
  
          //Stream stream = new MemoryStream(rawFile);
          //DataContractJsonSerializer obj = newDataContractJsonSerializer(typeof(string));
          //string result = obj.ReadObject(stream).ToString();
  
          //Deserializing
          MemoryStream stream = new MemoryStream();
          BinaryFormatter binForm = new BinaryFormatter();
          stream.Write(rawFile, 0, rawFile.Length);
  
          stream.Seek(0, SeekOrigin.Begin);
          Object obj = (Object) binForm.Deserialize(stream);
  
          System.Web.Script.Serialization.JavaScriptSerializer xyz = new System.Web.Script.Serialization.JavaScriptSerializer();
          string ejson = xyz.Serialize(obj);
  
          WebOperationContext.Current.OutgoingRequest.ContentType = "text/json";
          return ejson;
      }
  </code></pre>
  
  <p>I'm trying to return a string and it's not working, but when I return just the stream it's popping up the "openwith" message. </p>
  
  <p>Also should I use the <code>GET</code> or <code>POST</code> on my datacontract. I'm using REST in C#.</p>