开发者

Why is this cshtml giving run time error

开发者 https://www.devze.com 2023-04-03 14:27 出处:网络
Can anybody tell me why is this code giving runtime error: @if (Request.IsAuthenticated) { Welcome <b>Page.User.Identity.Name;</b>!

Can anybody tell me why is this code giving runtime error:

  @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 />     

}

What should I do to avoid it? I am getting crazy behind these braces and html mixed up


I'll give it a shot:

@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 />     
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消