Craig
Craig

Reputation: 18724

Have an MVC ActionLink - Need a 'li'

At the moment, on a form, I display a Logout button like this:

@Html.ActionLink("Logout", "LogoutUser", "User", null, new { @class = "btn btn-info" })

So, it calls LogoutUser in the UserController.

I am trying to add the logout to my menu at the top of the screen, which is built using

  • format.

    But, I am not sure how to convert that ActionLink into a li.

    <li><a href="#">Reports</a></li>
                        <li><a href="#">About</a></li>
                        <li><a href="#">Contact Us</a></li>
                        @if (User.Identity.IsAuthenticated)
                        {
                            <li>
                                <a href="~/Controllers/UserController/LogoutUser">Logout</a>
                            </li>
                        }
                        else
                        {
                        <li><a href="#login" data-toggle="modal">Login</a></li>    
                        }
    

    How do I get what I am trying to achieve?

    Upvotes: 0

    Views: 70

  • Answers (1)

    Matt Bodily
    Matt Bodily

    Reputation: 6413

    replace your a tag with the

    @Html.ActionLink("Logout", "LogoutUser", "User", null, new { @class = "btn btn-info" })
    

    Upvotes: 1

    Related Questions