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 7730471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:13:57+00:00 2026-06-01T06:13:57+00:00

In my ASP.NET application, i have a procedure that log all exceptions to a

  • 0

In my ASP.NET application, i have a procedure that log all exceptions to a file (using Application_Error() and global.asax). Inside that procedure, I log several things like current datetime, user name and such.

It works well, however, if someone (that is already logged) try to access a page that doesn’t exists (eg : http://www.mywebsite.com/foo.aspx) current user name information cannot be accessed from procedure, because System.Web.HttpContext.Current.Session is null. At first, i was thinking that session has been lost. it is not true, because if i press back i can still use the website (links still works without being redirected to login page).

What is the reason of session being null if a ressource is not found ? is it because session object is only initialized by asp after he know which page to deliver ? or maybe something is not configurated correctly on my website ?

  • 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-06-01T06:13:58+00:00Added an answer on June 1, 2026 at 6:13 am

    Take a look at the ASP.NET event lifecycle:

    http://msdn.microsoft.com/en-us/library/bb470252.aspx

    In particular, how HttpApplication processes your request. Note, that before BeginRequest (no.3) and AcquireRequestState (no.12) there are at least few important events.

    Now then, your session is available only after AcquireRequestState. If you have any error in one of prior events, you’ll get the null reference on Session.

    “Resource not found” is just one example but in general you have to be prepared that Session is just not available in early events of the processing pipeline.

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

Sidebar

Related Questions

I have a lot of data-entryists using my ASP.NET application and we have all
Suppose you have the following... An ASP.NET web application that calls a stored procedure
I created a global.asax file for an asp.net application. I run some code in
in a ASP.NET application (MVC) I have a foreach loop that loops through a
In my ASP .NET MVC application i have a link that refreshes the preview
I have an ASP.NET application that is hosted in timezone A and is being
I have a stored procedure which uses the IN clause. In my ASP.NET application,
I have some strange behavior occurring in an ASP.NET application that I am trying
I have an ASP.NET application which needs to search a VARCHAR(20) column using lists
I have an ASP.NET 4.0 application that handles survey responses. I want to dynamically

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.