Strange Behavior of Null Enum Types

I use Global.asax to log at the end of each request through the Application_EndRequest event. However, I see some odd behavior of some values ​​stored in the HTTPContext.Current.Items collection.

Below is the debug output for NULL with a null value. You can see that there is a value, but HasValue is allowed to False ?!

{System.Nullable(Of AreaNameEnum)}
    HasValue: False
    hasValue: False
    Value: {System.InvalidOperationException}
    value: ADMIN {0}

I assume it's too late in the request lifecycle to access HTTPContext.Current - but it seems to work sometimes, and sometimes not. Can anyone shed light on what is happening?

thanks

+5
source share
1 answer

Nullable - , hasValue T, T - . . enum 0 , public Value , hasValue .

, , , Nullable , . - , , hasValue . , null, Nullable.

+4

All Articles