有人能告诉我为什么这段代码会给出运行时错误:
@if (Request.IsAuthenticated) {
Welcome <b>Page.User.Identity.Name;</b>!
[ Html.ActionLink("Log Off", "LogOff", "Account"); ]
<br />
<br />
[ Html.ActionLink("Change Password", "ChangePassword", "Account"); ]
<br />
}
else {
[Html.ActionLink("Candidate Login", "LogOn", "Account",new { id = 1 },null);]
<br />
<br />
[Html.ActionLink("Employer Login", "LogOn", "Account", new { id = 2 }, null);]
<br />
}
我该怎么做才能避免它?我在这些大括号后面变得疯狂,html混淆了
答案 0 :(得分:1)
我会试一试:
@if (Request.IsAuthenticated) {
Welcome <b>@Page.User.Identity.Name</b>!
@Html.ActionLink("Log Off", "LogOff", "Account")
<br />
<br />
@Html.ActionLink("Change Password", "ChangePassword", "Account")
<br />
}
else
{
@Html.ActionLink("Candidate Login", "LogOn", "Account",new { id = 1 },null)
<br />
<br />
@Html.ActionLink("Employer Login", "LogOn", "Account", new { id = 2 }, null)
<br />
}