If you are having problems with the GetPageviewByPageID method (Dynamicweb.Frontend.PageView.GetPageviewByPageID( somepageid ).Output() it's because the <head> tag conflics with the excisting <head> on the current page.
So how can we extract the content of only the <body> tag?? No worries the solution is here :)
Use this function instead:
@functions {
string GetPageContent(int pageId) {
try {
var url = string.Format( "http://{0}/Default.aspx?ID={1}", @GetGlobalValue("Global:Request.Host"), pageId );
System.Net.WebClient client = new System.Net.WebClient();
Byte[] requestedHTML;
requestedHTML = client.DownloadData( url );
System.Text.UTF8Encoding objUTF8 = new System.Text.UTF8Encoding();
string html = objUTF8.GetString( requestedHTML );
var content = System.Text.RegularExpressions.Regex.Split( html, @"((?:.(?!<\s*body[^>]*>))+.<\s*body[^>]*>)|(<\s*/\s*body\s*\>.+)" )[0];
content = content.Trim();
return content;
}
catch { }
return null;
}
}
<div>@GetPageContent( pageId )</div>