Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 202419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:17:18+00:00 2026-05-11T17:17:18+00:00

I am using Global.asax to perform logging at the end of each request via

  • 0

I am using Global.asax to perform logging at the end of each request via the Application_EndRequest event. However, I am seeing some odd behavior of certain values stored in the HTTPContext.Current.Items collection.

Below is the debug output for a nullable Enum. You can see that there is a value, but HasValue resolved to False?!

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

I am guessing that it is too late in the request lifecycle to access the HTTPContext.Current – but it seems to sometimes work and sometimes not. Can anyone shed any more light on exactly what is going on?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:17:18+00:00Added an answer on May 11, 2026 at 5:17 pm

    Nullable is a structure that contains a boolean hasValue and a T value where T is a value type. In this case an enum. The enum has to have some value in this case the default 0, however the public Value throws an exception because hasValue is false.

    What you are seeing is the internals of how Nullable does what it does. You cannot read anything into the internal value field having any value when hasValue is false. After all if value could contain null there wouldn’t be any point in using Nullable here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to handle the application_start event without using the global.asax? The
I'm using code in the Application_BeingRequest() handler of my Global.asax to do some very
In Application_Start event in global.asax.cs, I have added some initialization code. This code is
How can I pass some data from a Global.asax event handler to a custom
I've recently discovered a way to implement RESTful services using Global.asax (by handling the
To use your own ModelMetadataProvider you normally set it in the global.asax. I'm using
plz see my global.asax : using System; using System.Collections.Generic; using System.Linq; using System.Web; using
In Global.asax we register routes using: MapRoute(this System.Web.Routing.RouteCollection routes, string name, string url, object
I'm having a void in my Global.asax, looking like this using System; using System.Collections.Generic;
I'm using autofac with asp.net. In Global.asax I register all my web pages: AssertNotBuilt();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.