I’m new to ASP.NET MVC and am using version 1.0 of the framework. I have a site.master page with the following hard-coded menu
<div id="menucontainer">
<ul id="menu">
<li><%= Html.ActionLink("Home", "Index", "Home")%></li>
<li><%= Html.ActionLink("Drivers", "List/?category=Drivers", "Product")%></li>
<li><%= Html.ActionLink("Irons", "List/?category=Irons", "Product") %></li>
<li><%= Html.ActionLink("Wedges", "List/?category=Wedges", "Product") %></li>
<li><%= Html.ActionLink("Putters", "List/?category=Putters", "Product") %></li>
</ul>
</div>
I want to show an extra item on the menu only if users are logged on. Something like “View My Listings”. I have no problem doing this in a dirty hacky way so I have tried
<% if (User.Identity.IsAuthenticated) ...
but User is not valid in this context. My question is how to show an extra menu item only if users are logged on?
You can access the User object through the Context object: