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