473,323 Members | 1,560 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,323 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>
Nov 22 '05 #1
0 904

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. ----------------------------------------------------------------------------...
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...
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...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.