473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access to path 'XYZ' is denied

I am trying to write an Ad Rotator component on my ASP.NET site,but keep running into an "interesting" problem. The routinestarts out by submitting the new ad information to the database(this part works fine), then attempts to write/append to astructured XML document (this is where it gets "interesting"). The system will attempt to write to the hard-coded XML documentand fail with the error message "Access to the path\"c:\\inetpub\\wwwroot\\H4\\Config\\AdRotator. Xml\" is denied.".However, the program will once again attempt the entire saveroutine (including writing to the DB, thereby duplicatingrecords), only this time it will write to the XML filecorrectly! Here is my code (in case it helps):

ASP.NET page
============
private void OKButton_Click(object sender, System.EventArgs e){
TheseAds.Business.Advertisement newAd = newTheseAds.Business.Advertisement();
newAd.ImageUrl = ImageURL.Text;
newAd.Description = Description.Text;
newAd.TrueNavigateUrl = NavigateURL.Text;
newAd.KeyWord = Keyword.Text;
newAd.AlternateText = AlternateText.Text;
newAd.CompanyID =Convert.ToInt32(CompaniesListBox.ItemsCompaniesLi stBox.SelectedIndex].Value);
newAd.Create();
Response.Redirect("Admin.aspx");
}

Business.Advertisement
======================
public void Create(){
HttpContext context = HttpContext.Current;
Configuration.ModuleSettings settings =Configuration.ModuleConfig.GetSettings();
Data.Advertisement newAd = newData.Advertisement(settings.ConnectionString);
newAd.Create(imageUrl, trueNavigateUrl, alternateText, keyword,companyId, description,
context.Server.MapPath(settings.RotatorXmlFile));
}

Data.Advertisement
==================
public void Create(string imageUrl, string trueNavigateUrl,string alternateText, string keyword, int companyId, stringdescription, string rotatorFile){
int rowsAffected;
SqlParameter[] parameters = { new SqlParameter("@companyID",SqlDbType.Int, 4),
new SqlParameter("@description", SqlDbType.VarChar, 255),
new SqlParameter("@trueNavigateUrl", SqlDbType.VarChar,255),
new SqlParameter("@adID", SqlDbType.Int, 4)};
parameters[0].Value = companyId;
parameters[1].Value = description;
parameters[2].Value = trueNavigateUrl;
parameters[3].Direction = ParameterDirection.Output;

RunProcedure("usp_Ads_CreateAdvertisement", parameters, outrowsAffected);

// now that the new ad is in the DB, put the rest of the detailsin the Rotator's XML file.
Configuration.ModuleSettings settings =Configuration.ModuleConfig.GetSettings();

XmlDocument rotatorDom = new XmlDocument();
rotatorDom.Load(rotatorFile);
XmlElement temp;
XmlElement newAd = rotatorDom.CreateElement("Ad");

temp = rotatorDom.CreateElement("ImageUrl");
temp.InnerText = imageUrl;
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("NavigateUrl");
temp.InnerText = settings.PassThroughPage + "?AD=" +parameters[3].Value.ToString();
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("AlternateText");
temp.InnerText = alternateText;
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("Keyword");
temp.InnerText = keyword;
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("Impressions");
temp.InnerText = "1";
newAd.AppendChild(temp);

rotatorDom.DocumentElement.AppendChild(newAd);
try{
rotatorDom.Save(rotatorFile);
}
catch(Exception ex){
throw new AppException(ex.Message);
}
}

Any help at all will be greatly appreciated.
--------------------------------
From: Chris McKenzie

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>1KviZ+ZSfUOdN9mCJJM5oQ==</Id>
Jul 21 '05 #1
0 989

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Theerachet Pratoommanee | last post by:
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ----------------------------------------------------------------------------...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
0
by: Goran | last post by:
Hi I have created a very simple ASP.Net application that only consists of a CrystalReports Viewer, that has been connected to a .rpt file. When the page is loaded in the browser, the following...
0
by: Chris McKenzie via .NET 247 | last post by:
I am trying to write an Ad Rotator component on my ASP.NET site,but keep running into an "interesting" problem. The routinestarts out by submitting the new ad information to the database(this part...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
8
by: Jeremy Ames | last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
0
by: p.thorn.ru | last post by:
Hello, I am running db2 express-c 9.5 under linux (fedora 7), and my error log frequently shows messages like these: 2008-01-08-18.30.01.952964+180 I651334G1048 LEVEL: Error (OS) PID ...
0
by: Andy | last post by:
Thanks Peter, I thought I'd give an update on this problem. My application had 2 assemblies that contained classed for the Data access and business logic layer. It was on one of them that I was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.