Error writing XML for first time on APP_DATA

A

ankit.sri

Hi,
I have a issue deploying a MCMS based webapplication which is developed in
Asp.net 2.0 on the Production box, the issue is :There is a customized
configuration XML which is residing under the app_data of the application and
I have written a code for Write certain root names of that custom XML on the
Application start up on Global.asax.cs file to override certain Root Names
when the application starts up it works fine on the Development Machines but
when put on to the Production box it Shows an Error page for the first time
when the home page gets loaded and after that it works fine and the same
scenario does not brings any issue on the Development Machine, its just I am
rewriting Custom XML File on the App_Data folder, is there anything which
needs to be done on the WebServer or the Configuration ? Following is the
code I am using to Update the XML file on the App_data of the Application
written on Application_Start of global.asax.cs

System.Web.HttpContext httpContext = System.Web.HttpContext.Current;
string strFilePath =
System.Web.HttpContext.Current.Request.ApplicationPath;
string strNewFile;
strFilePath += "/App_Data/";
strNewFile = strFilePath + "CustomWebConfig.xml";
string strReplace =
System.Configuration.ConfigurationManager.AppSettings["root_channel_name"];
strReplace = "/" + strReplace + "/";

XmlDocument xmlDoc = new XmlDocument();
XmlDocument xmlDocNew = new XmlDocument();

xmlDoc.Load(httpContext.Server.MapPath(strFilePath +
"CustomWebConfigTemplate.xml"));

XmlNodeList nodeList = xmlDoc.SelectNodes("Key/Keys");

for (int i = 0; i < nodeList.Count - 1; i++)
{
nodeList.Attributes["Value"].Value =
nodeList.Attributes["Value"].Value.Replace("/{-1}/", strReplace);
}
xmlDoc.Save(httpContext.Server.MapPath(strNewFile));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top