Error executing template "Designs/bfa5-transport/_parsed/side.parsed.cshtml"
System.ArgumentException: Object type cannot be converted to target type.
   at RazorEngine.Compilation.CrossAppDomainCleanUp.CleanupHelper.Init(AppDomain domain, IPrinter printer)
   at RazorEngine.Compilation.CrossAppDomainCleanUp.InitHelper.CreateHelper()
   at RazorEngine.Compilation.ExecutionContextLessThread.CallHelperSafeHelper`2.AsAction()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at RazorEngine.Compilation.ExecutionContextLessThread.DefaultCallFunc[O](Func`1 f)
   at RazorEngine.Compilation.CrossAppDomainCleanUp..ctor(AppDomain toWatch, IPrinter printer)
   at RazorEngine.Compilation.CrossAppDomainCleanUp.CreateInitial()
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Lazy`1.get_Value()
   at System.Lazy`1.get_Value()
   at RazorEngine.Compilation.CrossAppDomainCleanUp.RegisterCleanup(String item, Boolean throwOnDefault)
   at RazorEngine.Compilation.CrossAppDomainCleanUp.RegisterCleanup(String item, Boolean throwOnDefault)
   at RazorEngine.Templating.InvalidatingCachingProvider.CacheTemplate(ICompiledTemplate template, ITemplateKey templateKey)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(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.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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @using System.Web; 2 @using Dynamicweb.Rendering; 3 @using Dynamicweb.Content; 4 @using Dynamicweb.Data; 5 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 6 7 @{ 8 // variables 9 var area = Pageview.Area; 10 var systemName = GetString("Item.Area.Systemnavn"); 11 12 var websiteTitel = GetString("Item.Area.Titel"); 13 var logoNormal = GetString("Item.Area.LogoNormal"); 14 var logoNegative = GetString("Item.Area.LogoNegativ"); 15 var newsPageId = GetString("Item.Area.Nyheder"); 16 var searchPageId = GetString("Item.Area.Soegeresultater"); 17 var materialsPageId = GetString("Item.Area.Materialer"); 18 var newsletterParagraphId = GetInteger("Item.Area.Nyhedsbrev"); 19 var googleAnalytics = GetString("Item.Area.GoogleAnalytics"); 20 var linkedIn = GetString("Item.Area.LinkedIn"); 21 var facebook = GetString("Item.Area.Facebook"); 22 var privacyPoliticsPageId = GetString("Item.Area.Privatlivspolitik"); 23 var cookiePageId = GetString("Item.Area.Cookie"); 24 var branches = getBranches(area, systemName); 25 26 // translations 27 var textSearchButton = Translate("Search", "Søg"); 28 var textSearchPlaceholder = Translate("Enter keyword...", "Indtast søgeord..."); 29 30 var topPageId = GetString("DwPageID_1"); 31 var topPageClass = ""; 32 if(topPageId == "3307"){ 33 topPageClass = "godstransport"; 34 } 35 if(topPageId == "3347"){ 36 topPageClass = "persontransport"; 37 } 38 if(topPageId == "3374"){ 39 topPageClass = "lagreogvareterminaler"; 40 } 41 if(topPageId == "3360"){ 42 topPageClass = "brandogredning"; 43 } 44 if(topPageId == "3387"){ 45 topPageClass = "jernbanetransport"; 46 } 47 if(topPageId == "3400"){ 48 topPageClass = "lufttransport"; 49 } 50 } 51 52 53 <!doctype html> 54 <html lang="da" itemscope="" itemtype="https://schema.org/Organization"> 55 <head> 56 <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="4ef71bed-c131-4d98-b60a-0e61262678de" data-blockingmode="auto" type="text/javascript"></script> 57 <meta charset="utf-8"> 58 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 59 60 <meta name="author" content=""> 61 <link rel="icon" href="/Files/Templates/Designs/bfa5-transport/../../../../favicon.ico"> 62 63 <title>@GetValue("Title")</title> 64 @GetValue("MetaTags") 65 @GetValue("CopyRightNotice") 66 67 68 <!-- google font --> 69 <link href="https://fonts.googleapis.com/css?family=Archivo:400,600" rel="stylesheet"> 70 <link href="https://fonts.googleapis.com/css?family=Heebo" rel="stylesheet"> 71 72 <!-- font awesome --> 73 <link href="/Files/Templates/Designs/bfa5-transport/css/libs/fontawesome/css/all.css" rel="stylesheet"> 74 75 <!-- css --> 76 <link href="/Files/Templates/Designs/bfa5-transport/css/styles.min.css" rel="stylesheet"> 77 <link href="/Files/Templates/Designs/bfa5-transport/css/pb-styles.css" rel="stylesheet"> 78 <link href="/Files/Templates/Designs/bfa5-transport/css/print.min.css" rel="stylesheet" media="print"> 79 <style> 80 iframe { 81 display:block !important; 82 } 83 </style> 84 <!-- google analytics --> 85 @googleAnalytics 86 87 <!-- dw standard scripts --> 88 89 @GetValue("Stylesheets") 90 @GetValue("Javascripts") 91 </head> 92 93 <body class="@topPageClass"> 94 95 <nav class="navbar navbar-expand-md navbar-white"> 96 <div class="container"> 97 98 <a class="navbar-brand navbar-brand--negative" href="/"> 99 <img src="@logoNegative" alt="@websiteTitel"> 100 </a> 101 <a class="navbar-brand navbar-brand--normal" href="/"> 102 <img src="@logoNormal" alt="@websiteTitel"> 103 </a> 104 105 <div> 106 <button class="navbar-search-toggler" type="button" data-toggle="modal" data-target="#searchModal"><i class="far fa-search"></i></button> 107 108 <button class="navbar-toggler" type="button"> 109 <i class="far fa-bars"></i> 110 </button> 111 </div> 112 113 <div id="navbar-main" class="collapse navbar-collapse"> 114 115 <ul class="navbar-nav ml-auto"> 116 117 <button class="navbar-close"><i class="far fa-times"></i></button> 118 119 <div class="logo"> 120 <a class="navbar-brand" href="/"><img src="@logoNegative" alt="@websiteTitel"></a> 121 </div> 122 123 <li class="nav-item dropdown"> 124 <a class="nav-link dropdown-toggle" href="" id="brancher"><span class="text">Brancher</span><i class="fal fa-angle-down"></i></a> 125 <div class="dropdown-menu" aria-labelledby="brancher"> 126 <div class="container"> 127 <section class="branches menu container"> 128 <div class="row"> 129 <ul> 130 @foreach (var branch in branches) 131 { 132 var id = branch.Id; 133 var title = branch.Title; 134 var description = branch.Description; 135 var image = branch.Image; 136 var link = branch.Link; 137 var color = branch.ColorCode; 138 <li class="col-sm-12 col-md-6 col-lg-4"> 139 <article itemtype="https://schema.org/Article" itemscope="" class="@color"> 140 <a itemprop="url" href="@link"> 141 <div class="image"> 142 <img src="@image" alt="@title" itemprop="image"> 143 </div> 144 <h3 itemprop="name">@title</h3> 145 </a> 146 </article> 147 </li> 148 } 149 </ul> 150 151 <div class="col-sm-12 btn-all btn-all--menu"> 152 <a href="/Default.aspx?ID=3545" class="btn btn-secondary">Se fælles brancheindhold</a> 153 </div> 154 155 </div> 156 </section> 157 </div> 158 </div> 159 </li> 160 <li class="nav-item"> 161 <a class="nav-link" href="Default.aspx?ID=3340"><span class="text">Om os</span></a> 162 </li> 163 <li class="nav-item"> 164 <a class="nav-link" href="Default.aspx?ID=3341"><span class="text">Kontakt</span></a> 165 </li> 166 </ul> 167 </div> 168 169 <div class="search"> 170 <form action="Default.aspx" method="get"> 171 <input name="ID" value="@searchPageId" type="hidden" autocomplete="off"> 172 <input class="form-control" type="text" placeholder="@textSearchPlaceholder" name="q"> 173 <button class="btn search" type="submit"><i class="fal fa-search"></i></button> 174 </form> 175 </div> 176 177 </div> 178 </nav> 179 180 <main class="main"> 181 @using Dynamicweb.Rendering; 182 @using Dynamicweb.Frontend; 183 @using Dynamicweb.Content.Items; 184 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 185 186 187 @{ 188 var pageId = Pageview.ID; 189 } 190 191 <section class="breadcrumb container"> 192 <div class="row"> 193 <div class="col-sm-12"> 194 @if(pageId != 3299 && pageId != 3413 && pageId != 3420 && pageId != 3441 && pageId != 3461 && pageId != 3401){ 195 @GetValue("DwNavigation(breadcrumb)") 196 } 197 </div> 198 </div> 199 </section> 200 201 @if(!string.IsNullOrEmpty(GetString("DwContent(intro)"))){ 202 <div id="intro">@GetValue("DwContent(intro)")</div> 203 } 204 205 <section class="materials materials--page container"> 206 <div class="row"> 207 208 <div class="col-md-4"> 209 <div class="sitenav"> 210 <div class="sitenav-box"> 211 <div class="header">Gå til</div> 212 <div class="arrow"><i class="fal fa-angle-down"></i></div> 213 @GetValue("DwNavigation(sidenav)") 214 </div> 215 <div class="sitenav-common"> 216 <h4>Fælles brancheindhold</h4> 217 <p>Vi har samlet fælles materialer for alle brancher her.</p> 218 <a href="/Default.aspx?ID=3545" class="btn btn-default">Se fælles brancheindhold</a> 219 </div> 220 <div class="sitenav-logo"> 221 <img src="/Files/Templates/Designs/bfa5-transport/img/bomaerke.png" alt="BAU transport og engros"> 222 </div> 223 </div> 224 </div> 225 226 <div class="cards col-md-8"> 227 228 @if(!string.IsNullOrEmpty(GetString("DwContent(page)"))){ 229 <article class="page" itemtype="https://schema.org/Article" itemscope=""> 230 <div id="page" class="content" itemprop="text">@GetValue("DwContent(page)")</div> 231 </article> 232 } 233 234 <div class="row"> 235 <div class="ul list" id="ContentHolderInner">@GetValue("DwContent(ContentHolderInner)")</div> 236 </div> 237 238 </div> 239 </div> 240 241 </section> 242 </main> 243 244 <footer class="footer"> 245 <div class="container"> 246 247 @* 248 <div class="row"> 249 <div class="col-md-3 logo"> 250 <img src="@logoNegative" alt="@websiteTitel"> 251 </div> 252 </div> 253 *@ 254 255 <div class="row"> 256 257 @foreach (var item in GetLoop("Item.Area.Adresser")) 258 { 259 var title = item.GetString("Item.Area.Adresser.Titel"); 260 var address = item.GetString("Item.Area.Adresser.Adresse"); 261 var zip = item.GetString("Item.Area.Adresser.Postnummer"); 262 var city = item.GetString("Item.Area.Adresser.By"); 263 264 var name = item.GetString("Item.Area.Adresser.Navn"); 265 var phone = item.GetString("Item.Area.Adresser.Telefon"); 266 var email = item.GetString("Item.Area.Adresser.Email"); 267 268 <div class="col-md-4 address" itemtype="http://schema.org/PostalAddress" itemscope=""> 269 <h4>@title</h4> 270 <p itemprop="streetAddress">@address</p> 271 <p><span itemprop="postalCode">@zip</span> <span itemprop="addressLocality">@city</span></p> 272 </div> 273 } 274 275 <div class="col-md-4 address" itemtype="http://schema.org/PostalAddress" itemscope=""> 276 @foreach (var item in GetLoop("Item.Area.Adresser")) 277 { 278 var name = item.GetString("Item.Area.Adresser.Navn"); 279 var phone = item.GetString("Item.Area.Adresser.Telefon"); 280 var email = item.GetString("Item.Area.Adresser.Email"); 281 if (!string.IsNullOrEmpty(name)) 282 { 283 <h4>Konsulent</h4> 284 } 285 else 286 { 287 <h4>Kontakt</h4> 288 } 289 <p> 290 @if (!string.IsNullOrEmpty(name)) { @name <br> } 291 @if (!string.IsNullOrEmpty(phone)) { <a href="tel:@phone" itemprop="telephone">@phone</a> <br> } 292 @if (!string.IsNullOrEmpty(email)) { <a href="mailto:@email" itemprop="email">@email</a> } 293 </p> 294 } 295 </div> 296 297 <div class="col-md-4 newsletter"> 298 <h4>Nyhedsbrev</h4> 299 @RenderParagraphContent(newsletterParagraphId) 300 </div> 301 302 </div> 303 304 <div class="row"> 305 <div class="col-md-12 privacy"> 306 <a href="/om-bau-transport-og-engros/om-bau/cookie-warning">Cookie politik</a> 307 </div> 308 </div> 309 @if (!string.IsNullOrEmpty(linkedIn) || !string.IsNullOrEmpty(facebook) || !string.IsNullOrEmpty(privacyPoliticsPageId)) 310 { 311 <div class="row"> 312 <div class="col-md-6 social"> 313 @if (!string.IsNullOrEmpty(linkedIn) || !string.IsNullOrEmpty(facebook)) 314 { 315 <ul> 316 @if (!string.IsNullOrEmpty(linkedIn)) 317 { 318 <li> 319 <a href="@linkedIn" target="_blank"><i class="fab fa-linkedin-in"></i></a> 320 </li> 321 } 322 @if (!string.IsNullOrEmpty(facebook)) 323 { 324 <li> 325 <a href="@facebook" target="_blank"><i class="fab fa-facebook-f"></i></a> 326 </li> 327 } 328 </ul> 329 } 330 </div> 331 <div class="col-md-6 privacy"> 332 @if (!string.IsNullOrEmpty(privacyPoliticsPageId)) 333 { 334 <a href="/Default.aspx?ID=@privacyPoliticsPageId">Privatlivspolitik</a> 335 } 336 </div> 337 </div> 338 } 339 340 </div> 341 @* 342 @if(!string.IsNullOrEmpty(cookiePageId) && HttpContext.Current.Request["bfa5-cookie"] == null){ 343 <div class="cookie" data-id="cookie-warning"> 344 <div class="cookie-content"> 345 <div class="text"> 346 <table> 347 <tbody> 348 <tr> 349 <td class="img"> 350 <i class="fal fa-exclamation-triangle"></i> 351 </td> 352 <td class="float"> 353 <p> 354 <b>Siden bruger cookies</b> 355 </p> 356 <p> 357 Hvis du fortsætter på siden, accepterer du vores brug af cookies. Du kan læse mere ved at klikke 358 <a href="/Default.aspx?ID=@cookiePageId">her</a> 359 . 360 </p> 361 </td> 362 </tr> 363 </tbody> 364 </table> 365 </div> 366 <div class="accept" style="">Acceptér</div> 367 </div> 368 </div> 369 } 370 *@ 371 </footer> 372 373 <div id="searchModal" class="modal fade" tabindex="-1" role="dialog"> 374 <div class="modal-dialog" role="document"> 375 <div class="modal-content"> 376 <div class="modal-body"> 377 <div class="container"> 378 <div class="row"> 379 <div class="search-field col-sm-12"> 380 <form action="Default.aspx" method="get"> 381 <input name="ID" value="@searchPageId" type="hidden" autocomplete="off"> 382 <input type="text" name="q" placeholder="@textSearchPlaceholder"> 383 <button type="submit"><i class="fal fa-search"></i></button> 384 </form> 385 </div> 386 </div> 387 </div> 388 </div> 389 </div> 390 </div> 391 </div> 392 <script src="/Files/Templates/Designs/bfa5-transport/js/scripts.min.js?v=1.3"></script> 393 <script src="/Files/Templates/Designs/bfa5-transport/js/pb-scripts.js?v=1.5"></script> 394 <script src="/Files/Templates/Designs/bfa5-transport/js/pb-scripts2.js?v=1.5"></script> 395 <script src="/Files/Templates/Designs/bfa5-transport/js/analytics.js?v=1.1"></script> 396 397 </body> 398 </html> 399 400 @functions { 401 public class Branch 402 { 403 public int Id { get; set; } 404 405 public string Title { get; set; } 406 407 public string Description { get; set; } 408 409 public string Image { get; set; } 410 411 public string Link { get; set; } 412 413 public string ColorCode { get; set; } 414 } 415 public List<Branch> getBranches(Area area, string systemName) 416 { 417 var branches = new List<Branch>(); 418 using (var itemReader = Database.CreateDataReader(CommandBuilder.Create("SELECT * FROM Page AS p INNER JOIN ItemType_" + systemName + "Branche AS b ON p.PageItemId = b.Id WHERE p.PageAreaID = {0} AND p.PageActive = {1} AND p.PageItemType = {2} Order By b.Sort ASC", area.ID, "True", systemName + "Branche"))) 419 { 420 while (itemReader.Read()) 421 { 422 var branch = new Branch 423 { 424 Id = int.Parse(itemReader["Id"].ToString()), 425 Title = itemReader["Titel"].ToString(), 426 Description = itemReader["Beskrivelse"].ToString(), 427 Image = itemReader["Billede"].ToString(), 428 Link = itemReader["Link"].ToString(), 429 ColorCode = itemReader["Farvekode"].ToString() 430 }; 431 branches.Add(branch); 432 } 433 itemReader.Close(); 434 itemReader.Dispose(); 435 } 436 return branches; 437 } 438 }