I notice User.Identity.Name appears to return the empty string when there is no user authenticated, rather than throwing a null reference exception.
It is valid to assume User.Identity.Name will never throw? Or should I be checking for null Identity before access.
I believe that the User object can be null if you haven't called
FormsAuthentication.SetAuthCookie(UserName, False)
or
FormsAuthentication.RedirectFromLoginPage(UserName, False)
It would probably be best to wrap in a try catch.
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