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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:15:08+00:00 2026-05-28T00:15:08+00:00

In Application_Start event in global.asax.cs, I have added some initialization code. This code is

  • 0

In Application_Start event in global.asax.cs, I have added some initialization code. This code is run in a spawned thread (created using new Thread()). The initialization code uses Server.MapPath to get the physical path of a file. However many times I get an error in the log files :
Server Operation is not available in this context
In any case I am catching the exception. The initialization is not critical since even if it does not succeed, it will not be a problem for me.
My question is:

  1. Why am I getting the Server not available error?
  2. Can the handled exception cause any problems like Invalid Viewstate during normal execution of the application. We noticed a lot of these – Invalid Viewstate later in the logs.
    I believe it cannot. Please correct me if I am wrong.

Thanks

Vikas

  • 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-28T00:15:09+00:00Added an answer on May 28, 2026 at 12:15 am

    the Server object is referenced via HttpContext.Current i.e. relative to the current request. I suspect its not available from Application_Start since there is no request present at that point. Regardless it won’t reliably be available from within separate thread because the threads run independently from each other, therefore any request may have started or finished before your thread tries to access it.

    Try using HostingEnvironment.MapPath() instead as that is a static method.

    • 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
It's most common practice to register routes in Application_Start event within global.asax.cs/vb file. But
How can I use the PostAuthenticateRequest event of Global.asax? I'm following this tutorial and
I have a class Application that my global.asax inherits from. The class has this
My Application_Start code on the global.asax takes 2-3 minutes to finish (long db queries,
I have error handling in Application_Error event of globals.asax file. Inside this event, I'm
I am trying to access the Cache in the Application_Start method of Global.asax. I
I have a multiple web sits asp.net application. In this application different domains using
I've put the following code in global.asax <%@ Application Language=VB %> <script runat=server> Sub
I am using VS 2008. I have created a new Asp.net web site project

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.