Error executing template "Designs/identity_v2/_parsed/espresso.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_af5df00725134e5b904b33a0e1cd77aa.Execute() in D:\dynamicweb.net\Solutions\id.espresso4.dk-e5\Files\Templates\Designs\identity_v2\_parsed\espresso.parsed.cshtml:line 43
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, 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 Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Co3.Espresso.Website.TemplateBases.Pages.PageBase 2 @using System.Data 3 @using System.IO 4 @using System.Web 5 @using System.Globalization 6 @using System.Web.Script.Serialization 7 @using Co3.Espresso.Website.Models.FrontEnd 8 @using Co3.Espresso.Website.Services 9 @using Co3.ID.Dw.Helpers 10 @using Co3.ID.Dw.Models.Frontend 11 @using Co3.ID.Dw.Models.Frontend.Ecommerce 12 @using Co3.ID.Dw.Models.Frontend.Users 13 @using Dynamicweb.Frontend 14 @using Dynamicweb.Ecommerce.Common 15 @using Dynamicweb.Environment 16 @using Dynamicweb.Security.UserManagement 17 @using Newtonsoft.Json 18 19 @{ 20 ShopType shopContext = SiteContext.CurrentSiteContext(); 21 22 bool isUserAuthenticated = shopContext == ShopType.B2B; 23 string globalAreaLang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 24 string globalAreaName = PageView.Current().Area.UrlName; 25 string culture = PageView.Current().Area.Culture; 26 int areaId = PageView.Current().Area.ID; 27 28 bool isStagingUrl = HttpContext.Current.Request.Url.Host.ToLowerInvariant().Contains("staging"); 29 bool isProductPage = HttpContext.Current.Request["productid"] != null; 30 31 bool globalPrefix = PageView.Current().Area.UrlIgnoreForChildren; 32 if (globalPrefix == true) 33 { 34 globalAreaName = string.Empty; 35 } 36 CultureInfo currencyCulture = new CultureInfo(Context.Currency.CultureInfo); 37 38 string currencySeparatorDecimal = PageView.Current().User != null ? ExecutingContext.GetCulture().NumberFormat.NumberDecimalSeparator : currencyCulture.NumberFormat.NumberDecimalSeparator; 39 string currencySeparatorInteger = PageView.Current().User != null ? ExecutingContext.GetCulture().NumberFormat.NumberGroupSeparator : currencyCulture.NumberFormat.NumberGroupSeparator; 40 41 string openGraphUrl = PageView.Current().SearchFriendlyUrl; 42 string openGraphImage = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + Espresso.OpenGraphImage; 43 bool loadGoogleTagManager = !string.IsNullOrEmpty(Espresso.Area.GoogleTagManagerID) && 44 !(Espresso.Area.Item.GoogleTagManagerDisableIfPerformanceTestIsDetected == "True" && HttpContext.Current.Request.UserAgent.ToLower().Contains("lighthouse")); 45 46 string espressoCriticalJsFile = HttpContext.Current.Server.MapPath("/Files/Templates/Designs/identity_v2/_assets/_dist/js/critical.js"); 47 string espressoCriticalJs = File.ReadAllText(espressoCriticalJsFile); 48 49 string espressoCriticalCssFile = HttpContext.Current.Server.MapPath("/Files/Templates/Designs/identity_v2/_assets/_dist/css/critical.css"); 50 string espressoCriticalCss = File.ReadAllText(espressoCriticalCssFile); 51 52 object campaignColors = Co3.ID.Dw.Services.AreaService.Instance.GetAreaCampaignSwatches(PageView.Current().AreaID); 53 54 bool shouldTrackRelewise = shopContext != ShopType.CustomerShop; 55 56 57 58 } 59 <!DOCTYPE html> 60 <html lang="@globalAreaLang" data-separator-integer="@currencySeparatorInteger" data-separator-decimal="@currencySeparatorDecimal" data-area="@globalAreaName" data-area-id="@areaId" data-state="@shopContext.ToString()" data-context="id" data-is-b2b="@(shopContext == ShopType.B2B)"> 61 <head> 62 <!-- The initial config of Consent Mode --> 63 64 <script> 65 window.dataLayer = window.dataLayer || []; 66 67 function gtag(){ dataLayer.push(arguments); } 68 69 gtag('consent', 'default', { 70 'ad_storage': 'denied', 71 'ad_user_data': 'denied', 72 'ad_personalization': 'denied', 73 'analytics_storage': 'denied', 74 'wait_for_update': 500 75 }); 76 gtag('set', 'ads_data_redaction', true); 77 </script> 78 79 <!-- Cookie Information Pop-up Script is required for the SDK --> 80 <script id="CookieConsent" src="https://policy.app.cookieinformation.com/uc.js" data-culture="@globalAreaLang.ToUpperInvariant()" data-gcm-version="2.0" type="text/javascript"></script> 81 82 83 @if (loadGoogleTagManager) 84 { 85 <!-- Google Tag Manager --> 86 <script> 87 (function(w, d, s, l, i) { 88 w[l] = w[l] || []; 89 w[l].push({ 90 'gtm.start': 91 new Date().getTime(), 92 event: 'gtm.js' 93 }); 94 95 var f = d.getElementsByTagName(s)[0], 96 j = d.createElement(s), 97 dl = l != 'dataLayer' ? '&l=' + l : ''; 98 j.async = true; 99 j.src = 100 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; 101 f.parentNode.insertBefore(j, f); 102 })(window, document, 'script', 'dataLayer', '@Espresso.Area.GoogleTagManagerID'); 103 </script> 104 <!-- End Google Tag Manager --> 105 } 106 @GetValue("CopyRightNotice") 107 <meta charset="utf-8"> 108 <meta content="width=device-width, initial-scale=1, shrink-to-fit=no, minimal-ui" name="viewport"> 109 <meta content="ie=edge" http-equiv="x-ua-compatible"> 110 <link href="https://cdnjs.cloudflare.com" rel="preconnect"> 111 <link href="https://www.googletagmanager.com" rel="preconnect"> 112 <link href="https://www.google-analytics.com" rel="preconnect"> 113 <link href="https://connect.facebook.net" rel="preconnect"> 114 <title>@GetValue("Title")</title> 115 <style> 116 @espressoCriticalCss 117 </style> 118 @RenderSnippet("webfonts") 119 <link id="identity-main-style" href="/Files/Templates/Designs/identity_v2/_assets/_dist/css/default.css?v=2.40" media="@Espresso.StylesheetAttributeMedia" rel="@Espresso.StylesheetAttributeRel" as="style"> 120 <script> 121 @espressoCriticalJs 122 </script> 123 @RenderingService.Instance.PartialView("_partials/productdesigner-load-cart.cshtml") 124 <script> 125 var campaignColors = @campaignColors; 126 var root = document.querySelector(':root'); 127 Object.keys(campaignColors).forEach(function (swatchKey){ 128 if(swatchKey.indexOf('BrandColor') > -1){ 129 root.style.setProperty(`--campaign-bg-${swatchKey.replace('BrandColor', '')}`, campaignColors[swatchKey]); 130 } else{ 131 root.style.setProperty(`--campaign-text-${swatchKey.replace('NeutralColor', '')}`, campaignColors[swatchKey]); 132 } 133 }); 134 </script> 135 <link rel="shortcut icon" href="@Espresso.Area.Item.Favicon"> 136 <meta name="description" content="@Espresso.DynamicwebPage.Description"> 137 @GetValue("MetaTags") 138 139 @if (Espresso.IsStagingUrl || string.Equals(Dynamicweb.Context.Current?.Request?.Url?.Host, 140 "id-identity.azureedge.net", 141 StringComparison.OrdinalIgnoreCase)) 142 { 143 <meta content="noindex,nofollow" name="robots"> 144 } 145 <meta property="og:url" content="@openGraphUrl"> 146 <meta property="og:title" content="@Espresso.OpenGraphTitle"> 147 <meta property="og:description" content="@Espresso.OpenGraphDescription"> 148 <meta property="og:image" content="@openGraphImage"> 149 <meta property="og:type" content="website"> 150 @if (string.IsNullOrEmpty(Espresso.Area.Item.GoogleSiteVerification) == false) 151 { 152 <meta name="google-site-verification" content="@Espresso.Area.Item.GoogleSiteVerification"> 153 } 154 155 @if (isStagingUrl == false) 156 { 157 <script> 158 window.sleeknoteSiteData || (window.sleeknoteSiteData = []); 159 </script> 160 } 161 162 163 164 @if (isStagingUrl == false) 165 { 166 <!-- Start of Sleeknote signup and lead generation tool - www.sleeknote.com --> 167 <script id='sleeknoteScript' type='text/javascript'> 168 (function () { var sleeknoteScriptTag = document.createElement('script'); 169 sleeknoteScriptTag.type = 'text/javascript'; 170 sleeknoteScriptTag.charset = 'utf-8'; 171 sleeknoteScriptTag.src = ('//sleeknotecustomerscripts.sleeknote.com/25665.js'); 172 var s = document.getElementById('sleeknoteScript'); 173 s.parentNode.insertBefore(sleeknoteScriptTag, s); 174 })(); 175 </script> 176 <!-- End of Sleeknote signup and lead generation tool - www.sleeknote.com --> 177 } 178 179 180 <script class="usercontext-gtm"> 181 dataLayer.push({ 182 'UserContext': '@shopContext.ToString()', 183 'event': 'UserContext' 184 }); 185 </script> 186 187 188 </head> 189 190 @{ 191 ClassList bodyClasses = new ClassList(); 192 bodyClasses.AddClasses( Espresso.Item.CustomClasses ); 193 194 bodyClasses.AddClasses($"shoptype-{shopContext.ToString()}"); 195 196 } 197 198 <body class="@bodyClasses" data-is-user-authenticated="@isUserAuthenticated.ToString().ToLower()" data-design="@Espresso.Area.DesignsFolderName" data-culture="@culture"> 199 200 @if (loadGoogleTagManager) 201 { 202 <!-- Google Tag Manager (noscript) --> 203 <noscript> 204 <iframe src="https://www.googletagmanager.com/ns.html?id=@Espresso.Area.GoogleTagManagerID" height="0" width="0" style="display: none; visibility: hidden"></iframe> 205 </noscript> 206 <!-- End Google Tag Manager (noscript) --> 207 } 208 209 @using Co3.Espresso.Website.Models.FrontEnd 210 @using Co3.Espresso.Website.Models.FrontEnd.Settings 211 @using Co3.Espresso.Website.Services 212 @using Dynamicweb.Frontend 213 @inherits Co3.Espresso.Website.TemplateBases.Pages.PageBase 214 @{ 215 Espresso.Canvas.Classes.AddClasses( "js-e-canvas is-loading" ); 216 if ( Espresso.Item.CanvasFullscreen == "True" ) 217 { 218 Espresso.Canvas.Classes.AddClasses( "is-fullscreen" ); 219 } 220 string campaignSplash = Espresso.Area.Item.CampaignSplash; 221 222 string redirect = GetGlobalValue("Global:Pageview.Url.Raw"); 223 HttpCookie userSavedAreaLanguage = HttpContext.Current.Request.Cookies[ "e4.redirect.language" ]; 224 HttpCookie userDisableRedirect = HttpContext.Current.Request.Cookies[ "e4.redirect.disabled" ]; 225 } 226 227 228 229 <div class="e-loading-overlay e-page-loading-overlay is-loading js-e-page-loading-overlay"> 230 @RenderingService.Instance.PartialView( "_partials/loading-spinner.cshtml" ) 231 </div> 232 233 @RenderingService.Instance.PartialView( "_partials/webfonts.cshtml", Espresso ) 234 <div class="@Espresso.Canvas.Classes"> 235 @RenderingService.Instance.PartialView( "_partials/header.cshtml", Espresso ) 236 @*@RenderingService.Instance.PartialView( "usermanagement/viewprofile/espresso-impersonate-user-msg.cshtml", Espresso )*@ 237 238 <main id="dwcontentmain" class="e-content js-e-content @Espresso.ContentArea.Classes"> 239 @RenderingService.Instance.PartialView( "_partials/breadcrumb.cshtml", Espresso ) 240 <article class="e-content-article"> 241 @RenderingService.Instance.PartialView( "_partials/nav-local-horizontal.cshtml", Espresso ) 242 @RenderingService.Instance.PartialView( "_partials/nav-local-vertical.cshtml", Espresso ) 243 @RenderingService.Instance.SectionStart( new SectionSettings() ) 244 @GetValue("DwContent(dwcontentmain)") 245 @RenderingService.Instance.SectionEnd() 246 </article> 247 </main> 248 249 @RenderingService.Instance.PartialView( "_partials/footer.cshtml", Espresso ) 250 251 @if ( !string.IsNullOrEmpty( GetString( "DwContent(dwcontentcta)" ) ) ) 252 { 253 <aside class="e-cta fixed-top is-hidden js-e-cta" id="dwcontentcta"> 254 @RenderingService.Instance.SectionStart( new SectionSettings 255 { 256 ContentClasses = new ClassList( "col-12" ), 257 OuterRowClasses = new ClassList("row no-gutters"), 258 InnerRowClasses = new ClassList("row no-gutters justify-content-center align-items-center") 259 } ) 260 @GetValue("DwContent(dwcontentcta)") 261 @RenderingService.Instance.SectionEnd() 262 263 </aside> 264 } 265 266 @RenderingService.Instance.PartialView( "ecom7/cartv2/step/espresso-cart-msg.cshtml" ) 267 </div> 268 269 @RenderingService.Instance.PartialView( "_partials/search.cshtml", Espresso ) 270 271 @RenderingService.Instance.PartialView( "_partials/back-to-top.cshtml", Espresso ) 272 @RenderingService.Instance.PartialView("/Extranet/partials/identity-login.cshtml", Espresso) 273 274 @if (string.IsNullOrEmpty(campaignSplash) == false) 275 { 276 int campaignSplashParagraphId; 277 int.TryParse(campaignSplash, out campaignSplashParagraphId); 278 if (campaignSplashParagraphId > 0) 279 { 280 @RenderParagraphContent(campaignSplashParagraphId); 281 } 282 283 } 284 285 @if ( 1 == 2 ) 286 { 287 @GetValue("DwCookieWarning") 288 } 289 290 @if ( userSavedAreaLanguage == null ) 291 { 292 //@RenderingService.Instance.PartialView( "_partials/redirect.cshtml" ) 293 } 294 else 295 { 296 string currentAreaLanguage = PageView.Current().Area.UrlName; 297 string savedAreaLanguage = userSavedAreaLanguage.Value; 298 bool disabledRedirectForSession = userDisableRedirect != null ? Boolean.Parse( HttpContext.Current.Request.Cookies[ "e4.redirect.disabled" ].Value ) : false; 299 300 if ( currentAreaLanguage != savedAreaLanguage && disabledRedirectForSession == false ) 301 { 302 string redirectUrl = string.Format( "{0}://{1}/{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, savedAreaLanguage); 303 HttpContext.Current.Response.Redirect(redirectUrl); 304 305 } 306 307 } 308 309 310 311 @if ( shouldTrackRelewise ) 312 { 313 314 IdentityProduct itemIdentityProduct = (IdentityProduct)HttpContext.Current.Items["IdentityProduct"]; 315 bool isRelewiseCategoryPage = PageView.Current().Page.Item["RelewiseCategory"] != null ? (bool)PageView.Current().Page.Item["RelewiseCategory"] : false; 316 317 if (isRelewiseCategoryPage) 318 { 319 string productCategory = (string)HttpContext.Current.Items["IdentityProductCategory"]; 320 if (!string.IsNullOrEmpty(productCategory)) 321 { 322 Co3.ID.Dw.Relewise.Services.TrackerService.Instance.TrackCategoryView(PageView.Current().Page.ID.ToString()); 323 } 324 } else if (!isProductPage && itemIdentityProduct == null) 325 { 326 Co3.ID.Dw.Relewise.Services.TrackerService.Instance.TrackContentView(PageView.Current().Page.ID.ToString()); 327 } else if (isProductPage && itemIdentityProduct != null) 328 { 329 Co3.ID.Dw.Relewise.Services.TrackerService.Instance.TrackProductView(itemIdentityProduct); 330 } 331 } 332 333 @Co3.ID.Dw.Services.ScriptService.Instance.RenderScripts() 334 @Co3.ID.Dw.Services.ScriptService.Instance.GetScript("default") 335 336 337 </body> 338 339 @GetValue("CopyRightNotice") 340 </html>