Error executing template "Designs/bfa5-transport/_parsed/forside.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()
   at System.Lazy`1.get_Value()
   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.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 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.Content; 183 @using Dynamicweb.Content.Items; 184 @using Dynamicweb.Data; 185 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 186 187 188 @{ 189 var paragraphService = new ParagraphService(); 190 var newsSlider = getNews(area, systemName, newsPageId, materialsPageId, true, 10); 191 var newsGeneral = getNews(area, systemName, newsPageId, materialsPageId, false, 3); 192 } 193 194 <section class="branches container"> 195 <div class="row"> 196 197 <h3 class="col-sm-12">Brancher</h3> 198 199 <ul> 200 @foreach (var branch in branches) 201 { 202 var id = branch.Id; 203 var title = branch.Title; 204 var description = branch.Description; 205 var image = branch.Image; 206 var link = branch.Link; 207 var color = branch.ColorCode; 208 <li class="col-sm-12 col-md-6 col-lg-4"> 209 <article itemtype="https://schema.org/Article" itemscope="" class="@color"> 210 <a itemprop="url" href="@link"> 211 <div class="image"> 212 <img src="@image" alt="@title" itemprop="image"> 213 </div> 214 <h3 itemprop="name">@title</h3> 215 </a> 216 </article> 217 </li> 218 } 219 </ul> 220 221 <div class="col-sm-12 btn-all"> 222 <a href="/Default.aspx?ID=3545" class="btn btn-primary">Se fælles brancheindhold</a> 223 </div> 224 225 </div> 226 </section> 227 228 @if (newsSlider.Count > 0) 229 { 230 <section class="slideshow container"> 231 232 <div class="row"> 233 <h3 class="col-sm-12">Seneste nyt</h3> 234 </div> 235 236 <ul class="ul slider slider--hidden"> 237 @foreach (var news in newsSlider) 238 { 239 <li class="li"> 240 <article itemtype="https://schema.org/Article" itemscope=""> 241 <a href="@news.Link" target="@news.LinkTarget" itemprop="url"> 242 <img src="@news.Image" alt="@news.Title" itemprop="image"> 243 <div class="body"> 244 <div class="subject">@news.Category</div> 245 <h3 class="title" itemprop="name">@news.Title</h3> 246 <div class="readmore">Læs mere</div> 247 </div> 248 <div class="gradient"></div> 249 </a> 250 </article> 251 </li> 252 } 253 </ul> 254 255 </section> 256 } 257 258 <section class="cards no-margin container"> 259 <div class="row"> 260 261 @if (newsSlider.Count == 0) 262 { 263 <p>&nbsp;</p> 264 <h3 class="col-sm-12">Seneste nyt</h3> 265 } 266 267 <ul id="news" class="ul box frontpage">@GetValue("DwContent(news)")</ul> 268 269 <div class="col-sm-12 btn-all"> 270 <a href="/Default.aspx?ID=@newsPageId" class="btn btn-secondary">Se alle nyheder</a> 271 </div> 272 273 </div> 274 </section> 275 276 @if (newsGeneral.Count > 0) 277 { 278 <section class="cards no-margin container"> 279 <div class="row"> 280 281 @if (newsSlider.Count == 0) 282 { 283 <h3 class="col-sm-12" style="margin-bottom: 0;">Seneste nyt</h3> 284 } 285 286 <ul class="ul"> 287 @foreach (var news in newsGeneral) 288 { 289 <li class="li col-md-4"> 290 <article itemtype="https://schema.org/Article" itemscope=""> 291 <a class="card" href="@news.Link" target="@news.LinkTarget" itemprop="url"> 292 <div class="image"> 293 <img src="@news.Image" alt="@news.Title" itemprop="image"> 294 </div> 295 <div class="body"> 296 <div class="subject">@news.Category</div> 297 <h3 class="title" itemprop="name">@news.Title</h3> 298 <div class="readmore">Læs mere</div> 299 </div> 300 </a> 301 </article> 302 </li> 303 } 304 </ul> 305 306 <div class="col-sm-12 btn-all"> 307 <a href="/Default.aspx?ID=@newsPageId" class="btn btn-secondary">Se alle nyheder</a> 308 </div> 309 310 </div> 311 312 </section> 313 } 314 315 @functions { 316 public class New 317 { 318 public int Id { get; set; } 319 320 public string Title { get; set; } 321 322 public string Description { get; set; } 323 324 public string Content { get; set; } 325 326 public string Link { get; set; } 327 328 public string LinkTarget { get; set; } 329 330 public string Category { get; set; } 331 332 public string Image { get; set; } 333 334 public List<Image> Images { get; set; } 335 } 336 337 public class Image 338 { 339 public int Id { get; set; } 340 341 public string Title { get; set; } 342 343 public string Path { get; set; } 344 345 public List<int> Branches { get; set; } 346 } 347 348 public List<New> getNews(Area area, string systemName, string newsPageId, string materialsPageId, bool showInSlider, int countMax) 349 { 350 var paragraphService = new ParagraphService(); 351 352 var news = new List<New>(); 353 using (var itemRenderReader = Database.CreateDataReader(CommandBuilder.Create("SELECT TOP " + countMax.ToString() + " * FROM Paragraph AS p INNER JOIN ItemType_" + systemName + "Nyhed AS n ON p.ParagraphItemId = n.Id WHERE p.ParagraphPageId = {0} AND p.ParagraphShowParagraph = 'True' AND p.ParagraphItemType = {1} AND n.VisIslider = {2} Order By n.Id DESC", newsPageId, systemName + "Nyhed", showInSlider))) 354 { 355 while (itemRenderReader.Read()) 356 { 357 var material = new New 358 { 359 Id = int.Parse(itemRenderReader["Id"].ToString()), 360 Title = itemRenderReader["Titel"].ToString(), 361 Description = itemRenderReader["Beskrivelse"].ToString(), 362 Content = itemRenderReader["Indhold"].ToString(), 363 Link = itemRenderReader["Link"].ToString(), 364 LinkTarget = itemRenderReader["Maal"].ToString(), 365 Image = itemRenderReader["Billede"].ToString(), 366 Category = itemRenderReader["Kategori"].ToString(), 367 Images = new List<Image>() 368 }; 369 370 if (!string.IsNullOrEmpty(material.Link) && material.Link.Contains("#")) 371 { 372 var paragraph = paragraphService.GetParagraph(int.Parse(material.Link.Split('#')[1])); 373 if (paragraph != null) 374 { 375 material.Link = "/Default.aspx?ID=" + materialsPageId + "&itemId=" + paragraph.ItemType + ":" + paragraph.ItemId; 376 } 377 } 378 /* 379 using (var itemImagesReader = Database.CreateDataReader(CommandBuilder.Create("SELECT * FROM ItemListRelation AS ir INNER JOIN ItemType_" + systemName + "Billede AS b ON ir.ItemListRelationItemId = b.Id WHERE ir.ItemListRelationItemListId = {0} Order By ir.ItemListRelationSort ASC", itemRenderReader["Billeder"].ToString()))) 380 { 381 while (itemImagesReader.Read()) 382 { 383 var image = new Image 384 { 385 Id = int.Parse(itemImagesReader["Id"].ToString()), 386 Title = itemImagesReader["Titel"].ToString(), 387 Path = itemImagesReader["Billede"].ToString(), 388 Branches = itemImagesReader["Brancher"].ToString().Split(',').Select(int.Parse).ToList() 389 }; 390 material.Images.Add(image); 391 } 392 } 393 */ 394 news.Add(material); 395 } 396 itemRenderReader.Close(); 397 itemRenderReader.Dispose(); 398 } 399 return news; 400 } 401 } 402 </main> 403 404 <footer class="footer"> 405 <div class="container"> 406 407 @* 408 <div class="row"> 409 <div class="col-md-3 logo"> 410 <img src="@logoNegative" alt="@websiteTitel"> 411 </div> 412 </div> 413 *@ 414 415 <div class="row"> 416 417 @foreach (var item in GetLoop("Item.Area.Adresser")) 418 { 419 var title = item.GetString("Item.Area.Adresser.Titel"); 420 var address = item.GetString("Item.Area.Adresser.Adresse"); 421 var zip = item.GetString("Item.Area.Adresser.Postnummer"); 422 var city = item.GetString("Item.Area.Adresser.By"); 423 424 var name = item.GetString("Item.Area.Adresser.Navn"); 425 var phone = item.GetString("Item.Area.Adresser.Telefon"); 426 var email = item.GetString("Item.Area.Adresser.Email"); 427 428 <div class="col-md-4 address" itemtype="http://schema.org/PostalAddress" itemscope=""> 429 <h4>@title</h4> 430 <p itemprop="streetAddress">@address</p> 431 <p><span itemprop="postalCode">@zip</span> <span itemprop="addressLocality">@city</span></p> 432 </div> 433 } 434 435 <div class="col-md-4 address" itemtype="http://schema.org/PostalAddress" itemscope=""> 436 @foreach (var item in GetLoop("Item.Area.Adresser")) 437 { 438 var name = item.GetString("Item.Area.Adresser.Navn"); 439 var phone = item.GetString("Item.Area.Adresser.Telefon"); 440 var email = item.GetString("Item.Area.Adresser.Email"); 441 if (!string.IsNullOrEmpty(name)) 442 { 443 <h4>Konsulent</h4> 444 } 445 else 446 { 447 <h4>Kontakt</h4> 448 } 449 <p> 450 @if (!string.IsNullOrEmpty(name)) { @name <br> } 451 @if (!string.IsNullOrEmpty(phone)) { <a href="tel:@phone" itemprop="telephone">@phone</a> <br> } 452 @if (!string.IsNullOrEmpty(email)) { <a href="mailto:@email" itemprop="email">@email</a> } 453 </p> 454 } 455 </div> 456 457 <div class="col-md-4 newsletter"> 458 <h4>Nyhedsbrev</h4> 459 @RenderParagraphContent(newsletterParagraphId) 460 </div> 461 462 </div> 463 464 <div class="row"> 465 <div class="col-md-12 privacy"> 466 <a href="/om-bau-transport-og-engros/om-bau/cookie-warning">Cookie politik</a> 467 </div> 468 </div> 469 @if (!string.IsNullOrEmpty(linkedIn) || !string.IsNullOrEmpty(facebook) || !string.IsNullOrEmpty(privacyPoliticsPageId)) 470 { 471 <div class="row"> 472 <div class="col-md-6 social"> 473 @if (!string.IsNullOrEmpty(linkedIn) || !string.IsNullOrEmpty(facebook)) 474 { 475 <ul> 476 @if (!string.IsNullOrEmpty(linkedIn)) 477 { 478 <li> 479 <a href="@linkedIn" target="_blank"><i class="fab fa-linkedin-in"></i></a> 480 </li> 481 } 482 @if (!string.IsNullOrEmpty(facebook)) 483 { 484 <li> 485 <a href="@facebook" target="_blank"><i class="fab fa-facebook-f"></i></a> 486 </li> 487 } 488 </ul> 489 } 490 </div> 491 <div class="col-md-6 privacy"> 492 @if (!string.IsNullOrEmpty(privacyPoliticsPageId)) 493 { 494 <a href="/Default.aspx?ID=@privacyPoliticsPageId">Privatlivspolitik</a> 495 } 496 </div> 497 </div> 498 } 499 500 </div> 501 @* 502 @if(!string.IsNullOrEmpty(cookiePageId) && HttpContext.Current.Request["bfa5-cookie"] == null){ 503 <div class="cookie" data-id="cookie-warning"> 504 <div class="cookie-content"> 505 <div class="text"> 506 <table> 507 <tbody> 508 <tr> 509 <td class="img"> 510 <i class="fal fa-exclamation-triangle"></i> 511 </td> 512 <td class="float"> 513 <p> 514 <b>Siden bruger cookies</b> 515 </p> 516 <p> 517 Hvis du fortsætter på siden, accepterer du vores brug af cookies. Du kan læse mere ved at klikke 518 <a href="/Default.aspx?ID=@cookiePageId">her</a> 519 . 520 </p> 521 </td> 522 </tr> 523 </tbody> 524 </table> 525 </div> 526 <div class="accept" style="">Acceptér</div> 527 </div> 528 </div> 529 } 530 *@ 531 </footer> 532 533 <div id="searchModal" class="modal fade" tabindex="-1" role="dialog"> 534 <div class="modal-dialog" role="document"> 535 <div class="modal-content"> 536 <div class="modal-body"> 537 <div class="container"> 538 <div class="row"> 539 <div class="search-field col-sm-12"> 540 <form action="Default.aspx" method="get"> 541 <input name="ID" value="@searchPageId" type="hidden" autocomplete="off"> 542 <input type="text" name="q" placeholder="@textSearchPlaceholder"> 543 <button type="submit"><i class="fal fa-search"></i></button> 544 </form> 545 </div> 546 </div> 547 </div> 548 </div> 549 </div> 550 </div> 551 </div> 552 <script src="/Files/Templates/Designs/bfa5-transport/js/scripts.min.js?v=1.3"></script> 553 <script src="/Files/Templates/Designs/bfa5-transport/js/pb-scripts.js?v=1.5"></script> 554 <script src="/Files/Templates/Designs/bfa5-transport/js/pb-scripts2.js?v=1.5"></script> 555 <script src="/Files/Templates/Designs/bfa5-transport/js/analytics.js?v=1.1"></script> 556 557 </body> 558 </html> 559 560 @functions { 561 public class Branch 562 { 563 public int Id { get; set; } 564 565 public string Title { get; set; } 566 567 public string Description { get; set; } 568 569 public string Image { get; set; } 570 571 public string Link { get; set; } 572 573 public string ColorCode { get; set; } 574 } 575 public List<Branch> getBranches(Area area, string systemName) 576 { 577 var branches = new List<Branch>(); 578 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"))) 579 { 580 while (itemReader.Read()) 581 { 582 var branch = new Branch 583 { 584 Id = int.Parse(itemReader["Id"].ToString()), 585 Title = itemReader["Titel"].ToString(), 586 Description = itemReader["Beskrivelse"].ToString(), 587 Image = itemReader["Billede"].ToString(), 588 Link = itemReader["Link"].ToString(), 589 ColorCode = itemReader["Farvekode"].ToString() 590 }; 591 branches.Add(branch); 592 } 593 itemReader.Close(); 594 itemReader.Dispose(); 595 } 596 return branches; 597 } 598 }