Error executing template "Designs/Swift/_parsed/Swift_PageNoLayout.parsed.cshtml"
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock(Stream stream, Int64 start, Int32 size)
at System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream, PEStreamOptions options, Int32 size)
at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream, PEStreamOptions options)
at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.SelectMetadataReference.Visit(Assembly assembly)
at RazorEngine.Compilation.ReferenceResolver.CompilerReference.DirectAssemblyReference.Visit[T](ICompilerReferenceVisitor`1 visitor)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.GetMetadataReferences(IEnumerable`1 references)
at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
@using Dynamicweb
@using Dynamicweb.Environment
@functions {
string GetCookieOptInPermission(string category)
{
bool categoryOrAllGranted = false;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
}
return categoryOrAllGranted ? "granted" : "denied";
}
bool AllowTracking()
{
bool allowTracking = true;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
allowTracking = consentAtLeastOne;
}
return allowTracking;
}
}
@{
string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
@* Branding Themes Fonts *@
var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0;
var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0;
var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png";
var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null;
var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID");
string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID");
bool allowTracking = AllowTracking();
// Schema.org details for PDP
string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : "";
bool isProductDetailsPage = !string.IsNullOrEmpty(productId);
bool isArticlePage = Model.ItemType == "Swift_Article";
string schemaOrgType = string.Empty;
if (isProductDetailsPage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
}
if (isArticlePage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
}
}
<!doctype html>
<html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
<head>
<!-- @swiftVersion -->
@* Required meta tags *@
<meta charset="utf-8">
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
<link rel="preload" href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" as="style">
<link rel="preload" href="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" as="script">
<link rel="shortcut icon" href="@favicon">
<link rel="apple-touch-icon" href="/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="googlebot-news" content="nosnippet">
@Model.MetaTags
<title>@Model.Title</title>
@* Bootstrap + Swift stylesheet *@
<link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
@if (disableWideBreakpoints != "disableBoth")
{
<style>
@@media ( min-width: 1600px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1520px;
}
}
</style>
if (disableWideBreakpoints != "disableUltraWideOnly")
{
<style>
@@media ( min-width: 1920px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1820px;
}
}
</style>
}
}
@* Branding and Themes min stylesheet *@
<link href="/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_@(Model.Area.ID).min.css?@cssLastModified.Ticks" rel="stylesheet" media="all" type="text/css" data-last-modified-content="@cssLastModified">
<script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks"></script>
<script type="module">
swift.Scroll.hideHeadersOnScroll();
swift.Scroll.handleAlternativeTheme();
//Only load if AOS
const aosColumns = document.querySelectorAll('[data-aos]');
if (aosColumns.length > 0) {
swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks', 'js');
document.addEventListener('load.swift.assetloader', function () {
AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
});
}
</script>
@* Google gtag method - always include even if it is not used for anything *@
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
</script>
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID))
{
<script>
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
</script>
if (allowTracking)
{
string adConsent = GetCookieOptInPermission("Marketing");
string analyticsConsent = GetCookieOptInPermission("Statistical");
<script>
gtag('consent', 'update', {
'ad_storage': '@adConsent',
'ad_user_data': '@adConsent',
'ad_personalization': '@adConsent',
'analytics_storage': '@analyticsConsent'
});
</script>
}
}
@if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
{
var GoogleAnalyticsDebugMode = "";
if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
{
GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
}
<script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
<script>
gtag('js', new Date());
gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
</script>
}
@if (!string.IsNullOrWhiteSpace(customHeaderInclude))
{
@RenderPartial($"Components/Custom/{customHeaderInclude}")
}
</head>
<body class="brand @(masterTheme)">
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
{
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
}
<div data-intersect></div>
<main id="content" @(schemaOrgType)>
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
@using System
@using Dynamicweb.Ecommerce.ProductCatalog
@{
string theme = "";
string gridContent = "";
if (Model.PropertyItem != null)
{
theme = !string.IsNullOrWhiteSpace(Model.PropertyItem.GetRawValueString("Theme")) ? " theme " + Model.PropertyItem.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
}
if (Model.Item != null)
{
gridContent = Model.Grid("Grid", "Grid", "default:true;sort:1", "Page");
}
bool doNotRenderPage = false;
//Check if we are on the poduct detail page, and if there is data to render
ProductViewModel product = new ProductViewModel();
if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
{
product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
if (string.IsNullOrEmpty(product.Id))
{
doNotRenderPage = true;
}
}
//Render the page
if (!doNotRenderPage)
{
string itemIdentifier = Model?.Item?.SystemName != null ? "item_" + Model.Item.SystemName.ToLower() : "item_Swift_Page";
if (theme != "")
{
<div class="@theme item_@itemIdentifier">
@gridContent
</div>
}
else
{
<div class="item_@itemIdentifier">
@gridContent
</div>
}
}
else
{
<div class="container">
<div class="alert alert-info" role="alert">@Translate("Sorry. There is nothing to view here")</div>
</div>
}
if (!Model.IsCurrentUserAllowed)
{
int signInPage = GetPageIdByNavigationTag("SignInPage");
int dashboardPage = GetPageIdByNavigationTag("MyAccountDashboardPage");
if (!Pageview.IsVisualEditorMode)
{
if (signInPage != 0)
{
if (signInPage != Model.ID)
{
Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + signInPage);
}
else
{
if (dashboardPage != 0)
{
Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=" + dashboardPage);
}
else
{
Dynamicweb.Context.Current.Response.Redirect("/");
}
}
}
else
{
<div class="alert alert-dark m-0" role="alert">
<span>@Translate("You do not have access to this page")</span>
</div>
}
}
else
{
<div class="alert alert-dark m-0" role="alert">
<span>@Translate("To work on this page, you must be signed in, in the frontend")</span>
</div>
}
}
}
</main>
@* Render any offcanvas menu here *@
@RenderSnippet("offcanvas")
</body>
</html>