How to download rendered content of *.aspx SitePage using SharePoint Online Rest API

Occasional Contributor
Hi

We are trying to download rendered content of SitePages ( relativeURL: /SitePages/fileName.aspx) But we are getting non rendered content;

For e.g.,:

This is sample SitePage:

FFB01_0-1587981043382.png

 

Following content is what we received when try to download this file:

We need proper rendered content of aspx file 

<%@ Page language="C#" Inherits="Microsoft.SharePoint.WebControls.ClientSidePage, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head>
<!--[if gte mso 9]><SharePoint:CTFieldRefs runat=server Prefix="mso:" FieldList="FileLeafRef,ClientSideApplicationId,PageLayoutType,CanvasContent1,BannerImageUrl,BannerImageOffset,PromotedState,FirstPublishedDate,LayoutWebpartsContent,_TopicHeader,_SPSitePageFlags"><xml>
<mso:CustomDocumentProperties>
<mso:PageLayoutType msdt:dt="string">Article</mso:PageLayoutType>
<mso:_SPSitePageFlags msdt:dt="string"></mso:_SPSitePageFlags>
<mso:CanvasContent1 msdt:dt="string">&lt;div&gt;&lt;div data-sp-canvascontrol=&quot;&quot; data-sp-canvasdataversion=&quot;1.0&quot; data-sp-controldata=&quot;&amp;#123;&amp;quot;controlType&amp;quot;&amp;#58;4,&amp;quot;id&amp;quot;&amp;#58;&amp;quot;48fd2e0a-d158-4113-b236-eeb4be0270d2&amp;quot;,&amp;quot;position&amp;quot;&amp;#58;&amp;#123;&amp;quot;zoneIndex&amp;quot;&amp;#58;1,&amp;quot;sectionIndex&amp;quot;&amp;#58;1,&amp;quot;controlIndex&amp;quot;&amp;#58;1,&amp;quot;layoutIndex&amp;quot;&amp;#58;1&amp;#125;,&amp;quot;emphasis&amp;quot;&amp;#58;&amp;#123;&amp;#125;&amp;#125;&quot;&gt;&lt;div data-sp-rte=&quot;&quot;&gt;&lt;p&gt;Hello Test, Addi&lt;strong&gt;ng sample content&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-sp-canvascontrol=&quot;&quot; data-sp-canvasdataversion=&quot;1.0&quot; data-sp-controldata=&quot;&amp;#123;&amp;quot;controlType&amp;quot;&amp;#58;3,&amp;quot;id&amp;quot;&amp;#58;&amp;quot;61d0a799-c797-49db-a4cd-ae169c8755f6&amp;quot;,&amp;quot;position&amp;quot;&amp;#58;&amp;#123;&amp;quot;zoneIndex&amp;quot;&amp;#58;1,&amp;quot;sectionIndex&amp;quot;&amp;#58;1,&amp;quot;controlIndex&amp;quot;&amp;#58;2,&amp;quot;layoutIndex&amp;quot;&amp;#58;1&amp;#125;,&amp;quot;webPartId&amp;quot;&amp;#58;&amp;quot;7b317bca-c919-4982-af2f-8399173e5a1e&amp;quot;,&amp;quot;emphasis&amp;quot;&amp;#58;&amp;#123;&amp;#125;,&amp;quot;reservedHeight&amp;quot;&amp;#58;64,&amp;quot;reservedWidth&amp;quot;&amp;#58;832,&amp;quot;addedFromPersistedData&amp;quot;&amp;#58;true&amp;#125;&quot;&gt;&lt;div data-sp-webpart=&quot;&quot; data-sp-webpartdataversion=&quot;2.0&quot; data-sp-webpartdata=&quot;&amp;#123;&amp;quot;id&amp;quot;&amp;#58;&amp;quot;7b317bca-c919-4982-af2f-8399173e5a1e&amp;quot;,&amp;quot;instanceId&amp;quot;&amp;#58;&amp;quot;61d0a799-c797-49db-a4cd-ae169c8755f6&amp;quot;,&amp;quot;title&amp;quot;&amp;#58;&amp;quot;Code Snippet&amp;quot;,&amp;quot;description&amp;quot;&amp;#58;&amp;quot;Add a Code Snippet to the page&amp;quot;,&amp;quot;serverProcessedContent&amp;quot;&amp;#58;&amp;#123;&amp;quot;htmlStrings&amp;quot;&amp;#58;&amp;#123;&amp;quot;html&amp;quot;&amp;#58;&amp;quot;&amp;lt;div class=\&amp;quot;CodeMirror cm-s-monokai CodeMirror-wrap\&amp;quot;&amp;gt;&amp;lt;div style=\&amp;quot;overflow&amp;#58; hidden; position&amp;#58; relative; width&amp;#58; 3px; height&amp;#58; 0px; top&amp;#58; 3.9931px; left&amp;#58; 186.997px;\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-vscrollbar\&amp;quot; tabindex=\&amp;quot;-1\&amp;quot; cm-not-content=\&amp;quot;true\&amp;quot;&amp;gt;&amp;lt;div style=\&amp;quot;min-width&amp;#58; 1px; height&amp;#58; 0px;\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-hscrollbar\&amp;quot; tabindex=\&amp;quot;-1\&amp;quot; cm-not-content=\&amp;quot;true\&amp;quot;&amp;gt;&amp;lt;div style=\&amp;quot;height&amp;#58; 100%; min-height&amp;#58; 1px; width&amp;#58; 0px;\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-scrollbar-filler\&amp;quot; cm-not-content=\&amp;quot;true\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-gutter-filler\&amp;quot; cm-not-content=\&amp;quot;true\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-scroll\&amp;quot; tabindex=\&amp;quot;-1\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-sizer\&amp;quot; style=\&amp;quot;margin-left&amp;#58; 29px; margin-bottom&amp;#58; -19px; border-right-width&amp;#58; 11px; min-height&amp;#58; 24px; padding-right&amp;#58; 0px; padding-bottom&amp;#58; 0px;\&amp;quot;&amp;gt;&amp;lt;div style=\&amp;quot;position&amp;#58; relative; top&amp;#58; 0px;\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-lines\&amp;quot; role=\&amp;quot;presentation\&amp;quot;&amp;gt;&amp;lt;div role=\&amp;quot;presentation\&amp;quot; style=\&amp;quot;position&amp;#58; relative; outline&amp;#58; none;\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-measure\&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;span&amp;gt;xxxxxxxxxx&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-linenumber CodeMirror-gutter-elt\&amp;quot;&amp;gt;&amp;lt;div&amp;gt;1&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-measure\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div style=\&amp;quot;position&amp;#58; relative; z-index&amp;#58; 1;\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-cursors\&amp;quot; style=\&amp;quot;\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-cursor\&amp;quot; style=\&amp;quot;left&amp;#58; 158.003px; top&amp;#58; 0px; height&amp;#58; 16.6667px;\&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-code\&amp;quot; role=\&amp;quot;presentation\&amp;quot;&amp;gt;&amp;lt;div style=\&amp;quot;position&amp;#58; relative;\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-gutter-wrapper\&amp;quot; style=\&amp;quot;left&amp;#58; -28.993px;\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-linenumber CodeMirror-gutter-elt\&amp;quot; style=\&amp;quot;left&amp;#58; 0px; width&amp;#58; 21px;\&amp;quot;&amp;gt;1&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;pre class=\&amp;quot; CodeMirror-line \&amp;quot; role=\&amp;quot;presentation\&amp;quot;&amp;gt;&amp;lt;span role=\&amp;quot;presentation\&amp;quot; style=\&amp;quot;padding-right&amp;#58; 0.1px;\&amp;quot;&amp;gt;&amp;lt;span class=\&amp;quot;cm-variable\&amp;quot;&amp;gt;console&amp;lt;/span&amp;gt;.&amp;lt;span class=\&amp;quot;cm-property\&amp;quot;&amp;gt;log&amp;lt;/span&amp;gt;(&amp;lt;span class=\&amp;quot;cm-string\&amp;quot;&amp;gt;&#39;hello&#39;&amp;lt;/span&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div style=\&amp;quot;position&amp;#58; absolute; height&amp;#58; 11px; width&amp;#58; 1px; border-bottom&amp;#58; 0px solid transparent; top&amp;#58; 24px;\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-gutters\&amp;quot; style=\&amp;quot;height&amp;#58; 35px; left&amp;#58; 0.00695801px;\&amp;quot;&amp;gt;&amp;lt;div class=\&amp;quot;CodeMirror-gutter CodeMirror-linenumbers\&amp;quot; style=\&amp;quot;width&amp;#58; 29px;\&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;&amp;#125;,&amp;quot;searchablePlainTexts&amp;quot;&amp;#58;&amp;#123;&amp;quot;code&amp;quot;&amp;#58;&amp;quot;console.log(&#39;hello&#39;)&amp;quot;&amp;#125;,&amp;quot;imageSources&amp;quot;&amp;#58;&amp;#123;&amp;#125;,&amp;quot;links&amp;quot;&amp;#58;&amp;#123;&amp;#125;&amp;#125;,&amp;quot;dataVersion&amp;quot;&amp;#58;&amp;quot;2.0&amp;quot;,&amp;quot;properties&amp;quot;&amp;#58;&amp;#123;&amp;quot;language&amp;quot;&amp;#58;&amp;quot;JavaScript&amp;quot;,&amp;quot;lineNumbers&amp;quot;&amp;#58;true,&amp;quot;lineWrapping&amp;quot;&amp;#58;true,&amp;quot;theme&amp;quot;&amp;#58;&amp;quot;Monokai&amp;quot;&amp;#125;&amp;#125;&quot;&gt;&lt;div data-sp-componentid=&quot;&quot;&gt;7b317bca-c919-4982-af2f-8399173e5a1e&lt;/div&gt;&lt;div data-sp-htmlproperties=&quot;&quot;&gt;&lt;div data-sp-prop-name=&quot;html&quot;&gt;&lt;div class=&quot;CodeMirror cm-s-monokai CodeMirror-wrap&quot;&gt;&lt;div style=&quot;overflow&amp;#58;hidden;position&amp;#58;relative;width&amp;#58;3px;height&amp;#58;0px;top&amp;#58;3.9931px;left&amp;#58;186.997px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-vscrollbar&quot; tabindex=&quot;-1&quot;&gt;&lt;div style=&quot;min-width&amp;#58;1px;height&amp;#58;0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-hscrollbar&quot; tabindex=&quot;-1&quot;&gt;&lt;div style=&quot;height&amp;#58;100%;min-height&amp;#58;1px;width&amp;#58;0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-scrollbar-filler&quot;&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-gutter-filler&quot;&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-scroll&quot; tabindex=&quot;-1&quot;&gt;&lt;div class=&quot;CodeMirror-sizer&quot; style=&quot;margin-left&amp;#58;29px;margin-bottom&amp;#58;-19px;border-right-width&amp;#58;11px;min-height&amp;#58;24px;padding-right&amp;#58;0px;padding-bottom&amp;#58;0px;&quot;&gt;&lt;div style=&quot;position&amp;#58;relative;top&amp;#58;0px;&quot;&gt;&lt;div class=&quot;CodeMirror-lines&quot; role=&quot;presentation&quot;&gt;&lt;div role=&quot;presentation&quot; style=&quot;position&amp;#58;relative;outline&amp;#58;none;&quot;&gt;&lt;div class=&quot;CodeMirror-measure&quot;&gt;&lt;pre&gt;&lt;span&gt;xxxxxxxxxx&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;CodeMirror-linenumber CodeMirror-gutter-elt&quot;&gt;&lt;div&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-measure&quot;&gt;&lt;/div&gt;&lt;div style=&quot;position&amp;#58;relative;z-index&amp;#58;1;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-cursors&quot; style=&quot;&quot;&gt;&lt;div class=&quot;CodeMirror-cursor&quot; style=&quot;left&amp;#58;158.003px;top&amp;#58;0px;height&amp;#58;16.6667px;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-code&quot; role=&quot;presentation&quot;&gt;&lt;div style=&quot;position&amp;#58;relative;&quot;&gt;&lt;div class=&quot;CodeMirror-gutter-wrapper&quot; style=&quot;left&amp;#58;-28.993px;&quot;&gt;&lt;div class=&quot;CodeMirror-linenumber CodeMirror-gutter-elt&quot; style=&quot;left&amp;#58;0px;width&amp;#58;21px;&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;pre class=&quot; CodeMirror-line &quot; role=&quot;presentation&quot;&gt;&lt;span role=&quot;presentation&quot; style=&quot;padding-right&amp;#58;0.1px;&quot;&gt;&lt;span class=&quot;cm-variable&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;cm-property&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;cm-string&quot;&gt;&#39;hello&#39;&lt;/span&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;position&amp;#58;absolute;height&amp;#58;11px;width&amp;#58;1px;border-bottom&amp;#58;0px solid transparent;top&amp;#58;24px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;CodeMirror-gutters&quot; style=&quot;height&amp;#58;35px;left&amp;#58;0.00695801px;&quot;&gt;&lt;div class=&quot;CodeMirror-gutter CodeMirror-linenumbers&quot; style=&quot;width&amp;#58;29px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-sp-prop-name=&quot;code&quot; data-sp-searchableplaintext=&quot;true&quot;&gt;console.log(&#39;hello&#39;)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-sp-canvascontrol=&quot;&quot; data-sp-canvasdataversion=&quot;1.0&quot; data-sp-controldata=&quot;&amp;#123;&amp;quot;controlType&amp;quot;&amp;#58;0,&amp;quot;pageSettingsSlice&amp;quot;&amp;#58;&amp;#123;&amp;quot;isDefaultDescription&amp;quot;&amp;#58;true,&amp;quot;isDefaultThumbnail&amp;quot;&amp;#58;true&amp;#125;&amp;#125;&quot;&gt;&lt;/div&gt;&lt;/div&gt;</mso:CanvasContent1>
<mso:ContentTypeId msdt:dt="string">0x0101009D1CB255DA76424F860D91F20E6C41180024D6431AFAB9504E8EFE18E04387B9B1</mso:ContentTypeId>
<mso:ClientSideApplicationId msdt:dt="string">b6917cb1-93a0-4b97-a84d-7cf49975d4ec</mso:ClientSideApplicationId>
<mso:PromotedState msdt:dt="string">0</mso:PromotedState>
<mso:_TopicHeader msdt:dt="string"></mso:_TopicHeader>
<mso:BannerImageUrl msdt:dt="string"></mso:BannerImageUrl>
<mso:LayoutWebpartsContent msdt:dt="string">&lt;div&gt;&lt;div data-sp-canvascontrol=&quot;&quot; data-sp-canvasdataversion=&quot;1.4&quot; data-sp-controldata=&quot;&amp;#123;&amp;quot;id&amp;quot;&amp;#58;&amp;quot;cbe7b0a9-3504-44dd-a3a3-0e5cacd07788&amp;quot;,&amp;quot;instanceId&amp;quot;&amp;#58;&amp;quot;cbe7b0a9-3504-44dd-a3a3-0e5cacd07788&amp;quot;,&amp;quot;title&amp;quot;&amp;#58;&amp;quot;Title area&amp;quot;,&amp;quot;description&amp;quot;&amp;#58;&amp;quot;Title Region Description&amp;quot;,&amp;quot;serverProcessedContent&amp;quot;&amp;#58;&amp;#123;&amp;quot;htmlStrings&amp;quot;&amp;#58;&amp;#123;&amp;#125;,&amp;quot;searchablePlainTexts&amp;quot;&amp;#58;&amp;#123;&amp;#125;,&amp;quot;imageSources&amp;quot;&amp;#58;&amp;#123;&amp;#125;,&amp;quot;links&amp;quot;&amp;#58;&amp;#123;&amp;#125;&amp;#125;,&amp;quot;dataVersion&amp;quot;&amp;#58;&amp;quot;1.4&amp;quot;,&amp;quot;properties&amp;quot;&amp;#58;&amp;#123;&amp;quot;title&amp;quot;&amp;#58;&amp;quot;Hello Manku, This is a test page for SharePoint issue 595&amp;quot;,&amp;quot;imageSourceType&amp;quot;&amp;#58;4,&amp;quot;layoutType&amp;quot;&amp;#58;&amp;quot;FullWidthImage&amp;quot;,&amp;quot;textAlignment&amp;quot;&amp;#58;&amp;quot;Left&amp;quot;,&amp;quot;showTopicHeader&amp;quot;&amp;#58;false,&amp;quot;showPublishDate&amp;quot;&amp;#58;false,&amp;quot;topicHeader&amp;quot;&amp;#58;&amp;quot;&amp;quot;,&amp;quot;authors&amp;quot;&amp;#58;[&amp;#123;&amp;quot;id&amp;quot;&amp;#58;&amp;quot;i&amp;#58;0#.f|membership|ffbld01@ibmappcon.onmicrosoft.com&amp;quot;,&amp;quot;upn&amp;quot;&amp;#58;&amp;quot;ffbld01@ibmappcon.onmicrosoft.com&amp;quot;,&amp;quot;name&amp;quot;&amp;#58;&amp;quot;ffbld01@uk.ibm.com&amp;quot;,&amp;quot;role&amp;quot;&amp;#58;&amp;quot;&amp;quot;&amp;#125;],&amp;quot;authorByline&amp;quot;&amp;#58;[&amp;quot;i&amp;#58;0#.f|membership|&amp;quot;]&amp;#125;&amp;#125;&quot;&gt;&lt;/div&gt;&lt;/div&gt;</mso:LayoutWebpartsContent>
<mso:_AuthorByline msdt:dt="string">13;#i:0#.f|membership|ffbld01@ibmappcon.onmicrosoft.com</mso:_AuthorByline>
<mso:display_urn_x003a_schemas-microsoft-com_x003a_office_x003a_office_x0023__AuthorByline msdt:dt="string">ffbld01@uk.ibm.com</mso:display_urn_x003a_schemas-microsoft-com_x003a_office_x003a_office_x0023__AuthorByline>
</mso:CustomDocumentProperties>
</xml></SharePoint:CTFieldRefs><![endif]-->
<title>Hello Manku, This is a test page for SharePoint issue 595</title></head>

 

3 Replies

@FFB01 

 

If you download the aspx page, you get the ASP controls that render contents (which is what you're experiencing). 

 

If you're using Google Chrome, you can right click on the page and choose the "Save As" option. Other browsers likely have the same feature.

 

This will save the page as an HTML file, which you can then use to view the rendered content. 

 

It will not, however, be pretty.

@Will_Holland thanks for the reply. Actually we were wondering if there is any way by which we can request SharePoint to only give rendered content via ReST API.