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