how can i check if a user is logged in in user control with asp.net mvc
usually on a view page i use this
<% if (User.Identity.IsAuthenticated) {%> //Do something <% } %>
but i can't get this done on a user control
If you need to get the user from within the controller, use the User property of Controller. If you need it from the view, I would populate what you specifically need in the ViewData , or you could just call User as I think it's a property of ViewPage .
Nothing new to add to Griegs answer, but I would normally do
@Request.IsAuthenticated
Does this work?
<%= Page.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