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

  • Home
  • SEARCH
  • 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 598983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:26:55+00:00 2026-05-13T16:26:55+00:00

I am using Asp.net 3.5 and C# I have to add an XmlDocument to

  • 0

I am using Asp.net 3.5 and C#

I have to add an XmlDocument to my application state so that everytime my application doesnt access the XML file on my filesystem, I will add this at the Application_Start() function in Global.asax.cs

I am adding this to system state as :

protected void Application_Start(Object sender, EventArgs e)
{    
    string filePath = Server.MapPath("<path to my XML FILE>");
    XmlDocument xmlDoc = new XmlDocument();
    try
    {
        xmlTickerDoc.Load(filePath);
    }
    finally
    {
        HttpContext.Current.Application["xmlDoc"] = xmlDoc;
    }
}

In this code i try to load the xml file and if the file is not loaded due to any problem then i am wanting a null XmlDocument.

I access this XmlDocument as :

XmlDocument xmlDoc = new XmlDocument();
xmlDoc = HttpContext.Current.Application["xmlDoc"];

the error i get while build is

Cannot implicitly convert type ‘object’ to ‘System.Xml.XmlDocument’. An explicit conversion exists

So How to assign the HttpContext.Current.Application[“xmlDoc”] variable as System.Xml.XmlDocument ?

  • 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-13T16:26:55+00:00Added an answer on May 13, 2026 at 4:26 pm

    Got the answer after a little googling, a simple one but can be tricky for a PHP developer working on C# (as it was in my case)
    well i just had to explicitly cast my application state variable to XmlDocument
    that is at place of :

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc = HttpContext.Current.Application["xmlDoc"];
    

    I used :

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc = (XmlDocument) HttpContext.Current.Application["xmlDoc"];
    

    and it becomes Robust 🙂

    can any one tell me what will be the lifetime of this ApplicationState Variable ?

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

Sidebar

Related Questions

I am using asp.net MVC to develop an application that will have ajax interactions.
I'm using ASP.Net/C# and I have a form that allows people to add information
I'm using asp.net/c# and have a number of Collapsible Panel Extenders that have been
I have a web application using ASP.NET 2.0 and I want to know if
I have a control application - using asp.net webservices. I have a timer which
I have a website built using Asp.net and LinqToSql for Data Access. In a
I am in the start up of a project using ASP.NET MVC and have
Using asp.net, I need to generate a snapshot of an youtube video. I have
I have been using ASP.NET for years, but I can never remember when using
I am using ASP.NET Dynamic Data for a project and I have a table

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.