title: How to get response data from RestSharp to download for user?
body: <p>I am using RestSharp to call an HTTP service via a Querystring. The service generates a Word document.</p>
  
  <p>When I call this service, it looks like a Word document is being returned in the "Content" property, but I struggling to work out how to return this content to the user via the traditional download window as a word document for saving.</p>
  
  <pre><code>    public ActionResult DocGen(string strReportId)
      {
          var client = new RestClient("http://localhost:88");
  
          var request = new RestRequest("DocGen/{id}", Method.GET);
          request.AddUrlSegment("id", "1060"); // replaces matching token in request.Resource
  
          // execute the request
          //RestResponse response = (RestResponse) client.Execute(request);
          IRestResponse response = client.Execute(request);
  
          if (response.ErrorException != null)
          {
              const string message = "Error retrieving response.  Check inner details for more info.";
              var myException = new ApplicationException(message, response.ErrorException);
              throw myException;
          }
  
          // Important and simple line. response.rawbytes was what I was missing.
          return File(response.RawBytes,response.ContentType,"sample.doc");
      }
  </code></pre>
  
  <p>Should this be an action?</p>
  
  <p>The content type seems correct ie Word.11</p>
  
  <p>So how do I code get this Response.Content back to the user?</p>
  
  <p>Many thanks in advance.</p>
  
  <p>EDIT</p>
  
  <p>I was closer to the solution than I thought. Power to RestSharp I guess !! See above. Now there might be a better way, and I am all ears for any suggestions, but this is where I am at at present.</p>