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