Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay Google Doc in IFRAME in ASP.Net Application
    primarykey
    data
    text
    <p>I am working on an .net application that would allow users to attach the google doc link to the application and view/edit them from the application itself. I use Iframes to embed the google doc in my application.</p> <p>Since the google doc embedding in the application should happen offline,I am using the access token from Google API to get the URL and display. Iam having display problems in this. </p> <p>I have done everything related to getting the access token required to open a google doc "offline" as per Google API document. According to the google api developer document, while opening the google doc url I need to either pass the access token as a query parameter or as a request header ("Authorization" header). </p> <p>I tried using the Authorization header and opened the google doc url using the HttpWebRequest object, but I dont get the doc page opened correctly..</p> <h1>Code in aspx file</h1> <pre><code>htmlBuilder.AppendFormat("&lt;iframe src='ShowFiles.ashx?url={0}' id='myFrame' name='myFrame' width='100%' height='100%' marginheight='0' frameborder='0'&gt;&lt;/iframe&gt;", urlLink); </code></pre> <h1>Code in Generic Handler (ShowFiles.ashx) file</h1> <pre><code>// get the UrlLink from the Query Parameter (url) HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(urlLink); myHttpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36"; myHttpWebRequest.Headers.Add("Authorization", "Bearer " + accessToken); string pageContent = string.Empty; HttpWebResponse HttpWResp = (HttpWebResponse)myHttpWebRequest.GetResponse(); if (HttpWResp != null) { StreamReader sr = new StreamReader(HttpWResp.GetResponseStream()); pageContent = sr.ReadToEnd(); } context.Response.ContentType = HttpWResp.ContentType; context.Response.Write(pageContent); </code></pre> <p>The browser does open the google doc, but once opened it keeps saying "trying to connect to Google" and it keeps popping up alert saying "server doesnt respond"</p> <p>So I tried to use the access token as a query parameter to the URL LINK , but that doesnt seem to work at all. eg: urlLink = "<a href="http://google.docs.com/myDoc/myFile?access_token=fsdfsfsq4334234_df" rel="nofollow">http://google.docs.com/myDoc/myFile?access_token=fsdfsfsq4334234_df</a></p> <p>and set this url to iframe src</p> <pre><code>&lt;iframe src=urlLink&gt; </code></pre> <p>this doesnt work at all...</p> <p>I knew that if in the same browser I login to my google account where I have this google drive document (in another tab), then in my web application without this access token, my iframe loads the google doc perfectly, just by giving the doc url like</p> <p>http://google.docs.com/myDoc/myFile"></p> <p>I tried opening the url from the client side using jQuery ajax, then the google doc isopened and but becomes read only. </p> <pre><code>var jqXHR = $.ajax({ async: true, url: url, type: 'GET', xhr: function () { var xhr = new window.XMLHttpRequest(); return xhr; }, beforeSend: function (xhr) { if (xhr != null) xhr.setRequestHeader("Authorization", "Bearer " + token); } }); jqXHR.done(function (data, textStatus, xhr) { $("#myFrame").contents().find("html").html(xhr.responseText); }); </code></pre> <p>Can anyone help me in getting this google docs to be displayed correctly (in edit Mode) in the IFRAME within my web application</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload