473,569 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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: WebMatrixHostin g)
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("Lo gFileSwitch", "Local File Trace
Switch");
HttpRequest currRequest = HttpContext.Cur rent.Request;
string strPath = currRequest.Map Path(currReques t.ApplicationPa th);
Trace.Listeners .Add(new TextWriterTrace Listener(strPat h +
@"\SmallGame.lo g"));

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

Thanks,
José

Nov 18 '05 #1
5 1151
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******** ******@TK2MSFTN GP09.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: WebMatrixHostin g)
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("Lo gFileSwitch", "Local File Trace
Switch");
HttpRequest currRequest = HttpContext.Cur rent.Request;
string strPath = currRequest.Map Path(currReques t.ApplicationPa th);
Trace.Listeners .Add(new TextWriterTrace Listener(strPat h +
@"\SmallGame.lo g"));

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_MACHINENAM E 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_MACHINENAM E (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***@somewher e.nl> a écrit dans le message de
news:10******** *****@corp.supe rnews.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_MACHINENAM E 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_MACHINENAM E (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******** ********@TK2MSF TNGP10.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***@somewher e.nl> a écrit dans le message de
news:10******** *****@corp.supe rnews.com...
"José Joye" <jose.joye@__No _SPam__bluewin_ _maPS_oN__.ch> wrote in message
news:%2******** ********@TK2MSF TNGP10.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
3894
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 error, this happens only if try access the report on the SERVER, it I try on my local machine, it works just fine. Any help will be much appreciated....
4
2723
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 error messages are thrown. The application, web based, late binds to a series of assemblies, none of which are in the GAC. I have configured the...
3
2196
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 started). I also created an .aspx file to do testing The .aspx file opens fine in other directory from IE. As long as I put it in the application's...
12
5085
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 Files\projects_cig\e4e3b3da\3c20ac69" is denied. The error goes on to say that the ASP.NET is not authorized...
4
2246
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 it. The machine is win 2k server. IIS is installed. I have already run aspnet_regiis - i to reinstall the .net framework.
4
2905
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 below). I suppose I have some kind of permissions issue on the server? What recommendations can anyone propose? Thanks, -- Bruce
3
7946
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 C:\Inetpub\wwwroot\RunReportASP is the directory of my virtual directory for my app. In it's properties I did check "Write" as a permission. What else...
5
393
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 server. When a user selects a file from the ListBox & clicks the button to download the selected file, I am getting the following error: Access...
8
3051
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 data there. Thinks are working fine. But when I use GetShortPathName to get the short path for the above path, it fails with Access denied error. I...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.