<div class="col-md-3">
<h2>Application uses</h2>
<ul>
<li>Sample pages using ASP.NET Core MVC</li>
@{
if (ViewBag.Logined) @Html.Raw("<li><a href=\"Member\"Login target=\"_blank\"> Login </a></li>");
else @Html.Raw("<li><a href=\"Member\"Logout target=\"_blank\"> Logout </a></li>");
}
</ul>
</div>
請問我哪裡錯了,我把登入狀態存在ViewBag中(有的話是TRUE),但這樣寫compile過不了,語法問題求解
把夸號加上去就可以了
<div class="col-md-3">
<h2>Application uses</h2>
<ul>
<li>Sample pages using ASP.NET Core MVC</li>
@{
if (ViewBag.Logined)
{
@Html.Raw("<li><a href=\"Member\"Login target=\"_blank\"> Login </a></li>");
}
else
{
@Html.Raw("<li><a href=\"Member\"Logout target=\"_blank\"> Logout </a></li>");
}
}
</ul>
</div>