问题
In Fredrik's Blog post, he has an example of a C# if statement
@if (WebSecurity.IsAuthenticated) {
<li><a href="/user/login">Log in</a></li>
} else {
<li><a href="/user/logout">Log out</a></li>
}
But in VB I can't seem to figure out how to do the same thing
@If (HttpContext.Current.User.Identity.IsAuthenticated) Then
<div id="dialog-confirm" title="Log Out">
<div class="alert" title="Alert">
</div>
Are you sure?</div>
End If
This show's that my internal HTML markup is wrong.
Basically the following is valid
@If (HttpContext.Current.User.Identity.IsAuthenticated) Then
End If
but anything that goes inside the if statement is considered "code" and not "markup". What I need is to be able to put markup in there.
Does anyone know how to do a proper if statement in Razor VB?
回答1:
@Lucas pointed me in the right direction. This seems to be valid
@If (HttpContext.Current.User.Identity.IsAuthenticated) Then
@<div id="dialog-confirm" title="Log Out">
<div class="alert" title="Alert"></div>
<div>Are you sure?</div>
</div>
End If
来源:https://stackoverflow.com/questions/4173705/asp-net-mvc3-if-statements-in-vb