title: Displaying content of an attached file as base64 in IE browser using JavaScript
body: <p>I am calling a web service which returns a byte[] of an attachment. I then convert the byte[] to base64 string and return results to the client. i Then want to display this returned string in the browser (IE is necessary). i am getting file not found because i believe IE has URL length limit of a little over 2000. What are my options of displaying the attachment returned? If there's no way to display it, how can i prompt user to save the attachment to a certain location using JavaScript?</p>
  
  <p>Here's what I have:</p>
  
  <p>//Ascx page</p>
  
  <pre><code>  function retrieveAttachmentById() {
          var DTO = { 'p_attachmentID': "123", 'p_itemId': "1" };
          var url = "/_layouts/SharepointWebService/CustomService.asmx/GetAttachmentById";
          $.ajax
          ({
              type: "Post",
              url: url,
              data: JSON.stringify(DTO),
              async: false,
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function add(msg) {
                  var url = msg.d;
  
                  // display base64 content.
                  //  window.location(url) doesn't work in IE when url is over 2047 characters.                
  
              },
                      error: function () { }
          });
       }
  </code></pre>
  
  <p>//CustomService.asmx</p>
  
  <pre><code>[WebMethod]
      public string GetAttachmentById(int p_attachmentID, int p_itemId)
      {
          byte[] fileBuffer = //Call service passing in p_attachmentID and p_itemId
          var url64 = Convert.ToBase64String(fileBuffer); //Successful
          return url64;
      }
  </code></pre>
  
  <p>Any suggestions would be appreciated. </p>