473,385 Members | 1,942 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 denied when writting to Application directory

Hello,

I know the problem I'm having has been mentioned several time...
However, the answers provided are not crystal clear.

Here is my problem:
I'm building a small web service that I will host on an internet Server
provider site (eg: WebMatrixHosting)
To be able to trace how it reacts, I want to write information in a log
file. To do so, I want to use a tracelistener and write the information in a
log file located in the application directory.
Here is a snippet of what I do:

gLogFileSwitch = new TraceSwitch("LogFileSwitch", "Local File Trace
Switch");
HttpRequest currRequest = HttpContext.Current.Request;
string strPath = currRequest.MapPath(currRequest.ApplicationPath);
Trace.Listeners.Add(new TextWriterTraceListener(strPath +
@"\SmallGame.log"));

Doing this, I receive an "access denied error".
What is the correct way to go?

Thanks,
José

Nov 18 '05 #1
5 1146
Does you files have write access for ASP.NET?

--
Rocky Moore
www.HintsAndTips.com - ~ Developer Tips Welcome ~
www.RJSoft.com/Products/RJContentPanel/ - Free web user content control!

"José Joye" <jose.joye@__No_SPam__bluewin__maPS_oN__.ch> wrote in message
news:#h**************@TK2MSFTNGP09.phx.gbl...
Hello,

I know the problem I'm having has been mentioned several time...
However, the answers provided are not crystal clear.

Here is my problem:
I'm building a small web service that I will host on an internet Server
provider site (eg: WebMatrixHosting)
To be able to trace how it reacts, I want to write information in a log
file. To do so, I want to use a tracelistener and write the information in a log file located in the application directory.
Here is a snippet of what I do:

gLogFileSwitch = new TraceSwitch("LogFileSwitch", "Local File Trace
Switch");
HttpRequest currRequest = HttpContext.Current.Request;
string strPath = currRequest.MapPath(currRequest.ApplicationPath);
Trace.Listeners.Add(new TextWriterTraceListener(strPath +
@"\SmallGame.log"));

Doing this, I receive an "access denied error".
What is the correct way to go?

Thanks,
José


Nov 18 '05 #2
> I want to write information in a log file. To do so, I want to
use a tracelistener and write the information in a log file
located in the application directory. [...]
Doing this, I receive an "access denied error".
What is the correct way to go?


You need you loosen security settings on your log file, the account
IUSR_MACHINENAME needs write access to the file.

Create the file manually (e.g. using Notepad).
Right-click the file, choose Properties.
On the Security tab, add IUSR_MACHINENAME (MACHINENAME being your machine's
name).
Allow Read and Write access for this account.

Martin.
Nov 18 '05 #3
Thanks to both of you for the answer,

Applying your proposal solve the problem.
I will also update an XML file (where I will store usage information).
Is this the way to go. I mean : create initial files and give access to
those files?

Thanks,
José

"Martin Maat" <du***@somewhere.nl> a écrit dans le message de
news:10*************@corp.supernews.com...
I want to write information in a log file. To do so, I want to
use a tracelistener and write the information in a log file
located in the application directory. [...]
Doing this, I receive an "access denied error".
What is the correct way to go?
You need you loosen security settings on your log file, the account
IUSR_MACHINENAME needs write access to the file.

Create the file manually (e.g. using Notepad).
Right-click the file, choose Properties.
On the Security tab, add IUSR_MACHINENAME (MACHINENAME being your

machine's name).
Allow Read and Write access for this account.

Martin.

Nov 18 '05 #4
"José Joye" <jose.joye@__No_SPam__bluewin__maPS_oN__.ch> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks to both of you for the answer,

Applying your proposal solve the problem.
I will also update an XML file (where I will store usage information).
Is this the way to go. I mean : create initial files and give access to
those files?


It is the most straightforward way. If you intend to have a lot of files to
be written to that way and you need to create them from code, you may want
to try to set access rights for a folder and create all files in that
folder. My suggestion can get a bit cumbersome, especially if you deploy the
site to another machine or have to reinstall the lot for some reason.

Another thing to be aware of is synchronization. As your site gets more hits
and they come in simultaniously, the file may not be available for writing
because it is being written to on behalf of another visitor. You may want to
use a static XmlDocument member in your application class and use lock
statements with that or use mutexes to keep requests from getting in each
others' ways.

Martin.
Nov 18 '05 #5
Thanks for your detailled answer.

José
"Martin Maat" <du***@somewhere.nl> a écrit dans le message de
news:10*************@corp.supernews.com...
"José Joye" <jose.joye@__No_SPam__bluewin__maPS_oN__.ch> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks to both of you for the answer,

Applying your proposal solve the problem.
I will also update an XML file (where I will store usage information).
Is this the way to go. I mean : create initial files and give access to
those files?
It is the most straightforward way. If you intend to have a lot of files

to be written to that way and you need to create them from code, you may want
to try to set access rights for a folder and create all files in that
folder. My suggestion can get a bit cumbersome, especially if you deploy the site to another machine or have to reinstall the lot for some reason.

Another thing to be aware of is synchronization. As your site gets more hits and they come in simultaniously, the file may not be available for writing
because it is being written to on behalf of another visitor. You may want to use a static XmlDocument member in your application class and use lock
statements with that or use mutexes to keep requests from getting in each
others' ways.

Martin.

Nov 18 '05 #6

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

Similar topics

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...
4
by: RichB | last post by:
Hello, The .NET application I have just installed at a client web site is throwing a strange error. At first the applications works without any problems, but after 10 mins or so Access denied...
3
by: jliusolar | last post by:
Hi I am trying to figure out why an application get this error when I am trying to open the application's asmx file from localhost. I don't have indexing service running(it set as manual and not...
12
by: Chad Crowder | last post by:
Hi all, I hope someone can give me a hand, because I'm out of ideas. I keep getting this message: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
4
by: Martin | last post by:
Hi, I am getting an "Access Denied" error when attempting to browse asp.net pages. I have installed ASP.NET 1.1.4322 on a domain controller. The machine also has ASP.NET 1.0.3705 installed on...
4
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
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 ...
5
by: rn5a | last post by:
I have a ASPX page which has a ListBox & a Button. The ListBox lists all the files & directories existing in a directory on the server. I want to give users the option to download files from the...
8
by: =?Utf-8?B?dHVtYQ==?= | last post by:
I have a win32 application that creates a directory in Users's Application Data directory (Example: c:\users\<username>\Local Settings\Application Data\MyFolder) and writing application specific...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.