我使用Html.Raw展示广告横幅(如果存在)。 当我调试时,我看到它被调用两次,并且html页面完成加载。 但它不会打印任何内容。
<div class="banner-right">
@{
var dicbanner = new GetData().GetBanner();
tb_Banner bn2;
tb_Banner bn3;
dicbanner.TryGetValue(2, out bn2);
dicbanner.TryGetValue(3, out bn3);
//Im sure that bn2 is not null
if (bn2 != null)
{
var x = "<a href=\"" + bn2.link != null ? bn2.link : "" + "\"><img src=\"" + bn2.ImageName + "\"/></a>";
Html.Raw(x); // this does not print anything although x has a value.
Html.Raw("<p>this line also not be printed!</p>");
}
}
</div>