I have authenticated users to log on my system using this code:
FormsAuthentication.SetAuthCookie(user, false);
I want to hide my system menu for non authenticated users. Something like this:
<% if(???) {%>
<ul id="menu>
...
</ul>
<% } %>
How can I do this?
Thank you.
if (Request.IsAuthenticated)
(This is how it's done in the default ASP.NET MVC template)
if (Request.IsAuthenticated)
There's an example of this in the login user control of the basic mvc project.
if you want roles then
if (HttpContext.Current.User.IsInRole("myrole"))
I think you want to use:
<% if(this.User.Identity.IsAuthenticated) { %>
<% } %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With