473,394 Members | 1,806 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,394 software developers and data experts.

Cannot write text to the file located in IIS' wwwroot directory!


How can I write message to the file located in the wwwroot directory?
It seems that IIS protect these files.
Let make me cannot do the I/O writing sucessfully.
I try to open file's write privileage by file manager and IIS manager.
However, one PC is okay and another PC is not.

Any help on this will be greatly appreciated.
Regards,
--sambuela
Nov 21 '05 #1
6 9125
This is my source code:

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System"%>
<html>
<head><title>Write to file</title>
</head>
<body>
<%
Dim txtWriter As StreamWriter
txtWriter = File.CreateText(Server.MapPath("Hello.txt"))
txtWriter = New StreamWriter("Hello.txt")
txtWriter.WriteLine("Hi")
txtWriter.Close
Response.Write(" 'Hello.txt'was built sucessfully ")
%>

Regards,
--sambuela

"sambuela" wrote:

How can I write message to the file located in the wwwroot directory?
It seems that IIS protect these files.
Let make me cannot do the I/O writing sucessfully.
I try to open file's write privileage by file manager and IIS manager.
However, one PC is okay and another PC is not.

Any help on this will be greatly appreciated.
Regards,
--sambuela

Nov 21 '05 #2
Try reading this walkthrough:
Editing an Access Database with ADO.Net

http://msdn.microsoft.com/library/de...wtaccessdb.asp

look for the section that starts: "The ASP.NET user, by default, does not
have permission to write a record to a database or create a locking file
(.ldb) in the folder containing the database. You must give the ASP.NET user
these permissions."

I wonder why you are placing your access database into a web folder? You
run into security issues that way. Any reason you shouldn't place the
access db under a seperate folder like C:/MyApplication ?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
This is my source code:

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System"%>
<html>
<head><title>Write to file</title>
</head>
<body>
<%
Dim txtWriter As StreamWriter
txtWriter = File.CreateText(Server.MapPath("Hello.txt"))
txtWriter = New StreamWriter("Hello.txt")
txtWriter.WriteLine("Hi")
txtWriter.Close
Response.Write(" 'Hello.txt'was built sucessfully ")
%>

Regards,
--sambuela

"sambuela" wrote:

How can I write message to the file located in the wwwroot directory?
It seems that IIS protect these files.
Let make me cannot do the I/O writing sucessfully.
I try to open file's write privileage by file manager and IIS manager.
However, one PC is okay and another PC is not.

Any help on this will be greatly appreciated.
Regards,
--sambuela

Nov 21 '05 #3
Nick,
I wonder why you are placing your access database into a web folder? You
run into security issues that way. Any reason you shouldn't place the
access db under a seperate folder like C:/MyApplication ?

Just to test when you are lazy and don't want to set the settings of a
seperate folter.

(Not for real production or/and on a real production webserver of course)

:-)

Cor
Nov 21 '05 #4
Thanks for your information and suggestion.
However, I still don't know how to creat a asp.net user before grant it
to my folder. Currently, I still cannot write record to the file and Access
DB.
Can you instrutct me to do so and review my previous code? thanks.
Best Regards,
--sambuela

"Nick Malik [Microsoft]" wrote:
Try reading this walkthrough:
Editing an Access Database with ADO.Net

http://msdn.microsoft.com/library/de...wtaccessdb.asp

look for the section that starts: "The ASP.NET user, by default, does not
have permission to write a record to a database or create a locking file
(.ldb) in the folder containing the database. You must give the ASP.NET user
these permissions."

I wonder why you are placing your access database into a web folder? You
run into security issues that way. Any reason you shouldn't place the
access db under a seperate folder like C:/MyApplication ?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
This is my source code:

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System"%>
<html>
<head><title>Write to file</title>
</head>
<body>
<%
Dim txtWriter As StreamWriter
txtWriter = File.CreateText(Server.MapPath("Hello.txt"))
txtWriter = New StreamWriter("Hello.txt")
txtWriter.WriteLine("Hi")
txtWriter.Close
Response.Write(" 'Hello.txt'was built sucessfully ")
%>

Regards,
--sambuela

"sambuela" wrote:

How can I write message to the file located in the wwwroot directory?
It seems that IIS protect these files.
Let make me cannot do the I/O writing sucessfully.
I try to open file's write privileage by file manager and IIS manager.
However, one PC is okay and another PC is not.

Any help on this will be greatly appreciated.
Regards,
--sambuela


Nov 21 '05 #5
Your code is not the problem.

a) move the database out of the www folders unless you have a compelling
need for it to be there.
b) you don't have to create the aspnet user. It already exists. Your web
app is running as the aspnet user unless you change this fact using the
impersonate tag in the web.config. The Name of the aspnet user varies
depending on which version of the OS (and therefore, which version of IIS)
you are using. The account name usually has a prefix of ASPNET.

The step-by-step in in the walkthrough link I provided at the location I
described.

I copied the instructions here, since it appears that you have not read the
article:
------------------------ copied from MSDN article ---------------------
In this walkthrough you will use the third (and safest) method to grant
write permission.
1.. From the File Explorer, find the new Pets folder, normally located at
C:\Inetpub\wwwroot\Pets\Pets.
2.. Right-click the Pets folder, and select Properties.
3.. Select the Security tab, and click the Add button.
4.. Add the object name <YOURMACHINE>\ASPNET where <YOURMACHINE> is the
name of your machine. Click OK to return to the Security tab.
5.. Select the ASP.NET account, and add Write permission. This account is
named aspnet_wp account, ASP.NET MACHINE Account, or something similar.
6.. From the File Explorer, right-click the file Pets.mdb, and select
Properties.
7.. Select the Security tab, and click the Advanced button.
8.. Check "Inherit from parent the permissions entries that apply to child
objects". Click OK to accept the change.
-----------------------------------------
Hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Thanks for your information and suggestion.
However, I still don't know how to creat a asp.net user before grant it
to my folder. Currently, I still cannot write record to the file and
Access
DB.
Can you instrutct me to do so and review my previous code? thanks.
Best Regards,
--sambuela

"Nick Malik [Microsoft]" wrote:
Try reading this walkthrough:
Editing an Access Database with ADO.Net

http://msdn.microsoft.com/library/de...wtaccessdb.asp

look for the section that starts: "The ASP.NET user, by default, does not
have permission to write a record to a database or create a locking file
(.ldb) in the folder containing the database. You must give the ASP.NET
user
these permissions."

I wonder why you are placing your access database into a web folder? You
run into security issues that way. Any reason you shouldn't place the
access db under a seperate folder like C:/MyApplication ?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
> This is my source code:
>
> <%@ Import Namespace="System.IO" %>
> <%@ Import Namespace="System"%>
> <html>
> <head><title>Write to file</title>
> </head>
> <body>
> <%
> Dim txtWriter As StreamWriter
> txtWriter = File.CreateText(Server.MapPath("Hello.txt"))
> txtWriter = New StreamWriter("Hello.txt")
> txtWriter.WriteLine("Hi")
> txtWriter.Close
> Response.Write(" 'Hello.txt'was built sucessfully ")
> %>
>
> Regards,
> --sambuela
>
> "sambuela" wrote:
>
>>
>> How can I write message to the file located in the wwwroot directory?
>> It seems that IIS protect these files.
>> Let make me cannot do the I/O writing sucessfully.
>> I try to open file's write privileage by file manager and IIS manager.
>> However, one PC is okay and another PC is not.
>>
>> Any help on this will be greatly appreciated.
>> Regards,
>> --sambuela


Nov 21 '05 #6
Thank you very much.
It is very helpful.
I solve the problem after follow your instructions.
Cheers!
--sambuela

"Nick Malik [Microsoft]" wrote:
Your code is not the problem.

a) move the database out of the www folders unless you have a compelling
need for it to be there.
b) you don't have to create the aspnet user. It already exists. Your web
app is running as the aspnet user unless you change this fact using the
impersonate tag in the web.config. The Name of the aspnet user varies
depending on which version of the OS (and therefore, which version of IIS)
you are using. The account name usually has a prefix of ASPNET.

The step-by-step in in the walkthrough link I provided at the location I
described.

I copied the instructions here, since it appears that you have not read the
article:
------------------------ copied from MSDN article ---------------------
In this walkthrough you will use the third (and safest) method to grant
write permission.
1.. From the File Explorer, find the new Pets folder, normally located at
C:\Inetpub\wwwroot\Pets\Pets.
2.. Right-click the Pets folder, and select Properties.
3.. Select the Security tab, and click the Add button.
4.. Add the object name <YOURMACHINE>\ASPNET where <YOURMACHINE> is the
name of your machine. Click OK to return to the Security tab.
5.. Select the ASP.NET account, and add Write permission. This account is
named aspnet_wp account, ASP.NET MACHINE Account, or something similar.
6.. From the File Explorer, right-click the file Pets.mdb, and select
Properties.
7.. Select the Security tab, and click the Advanced button.
8.. Check "Inherit from parent the permissions entries that apply to child
objects". Click OK to accept the change.
-----------------------------------------
Hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Thanks for your information and suggestion.
However, I still don't know how to creat a asp.net user before grant it
to my folder. Currently, I still cannot write record to the file and
Access
DB.
Can you instrutct me to do so and review my previous code? thanks.
Best Regards,
--sambuela

"Nick Malik [Microsoft]" wrote:
Try reading this walkthrough:
Editing an Access Database with ADO.Net

http://msdn.microsoft.com/library/de...wtaccessdb.asp

look for the section that starts: "The ASP.NET user, by default, does not
have permission to write a record to a database or create a locking file
(.ldb) in the folder containing the database. You must give the ASP.NET
user
these permissions."

I wonder why you are placing your access database into a web folder? You
run into security issues that way. Any reason you shouldn't place the
access db under a seperate folder like C:/MyApplication ?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
> This is my source code:
>
> <%@ Import Namespace="System.IO" %>
> <%@ Import Namespace="System"%>
> <html>
> <head><title>Write to file</title>
> </head>
> <body>
> <%
> Dim txtWriter As StreamWriter
> txtWriter = File.CreateText(Server.MapPath("Hello.txt"))
> txtWriter = New StreamWriter("Hello.txt")
> txtWriter.WriteLine("Hi")
> txtWriter.Close
> Response.Write(" 'Hello.txt'was built sucessfully ")
> %>
>
> Regards,
> --sambuela
>
> "sambuela" wrote:
>
>>
>> How can I write message to the file located in the wwwroot directory?
>> It seems that IIS protect these files.
>> Let make me cannot do the I/O writing sucessfully.
>> I try to open file's write privileage by file manager and IIS manager.
>> However, one PC is okay and another PC is not.
>>
>> Any help on this will be greatly appreciated.
>> Regards,
>> --sambuela


Nov 21 '05 #7

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

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
0
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any...
4
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any...
9
by: Joe Rattz | last post by:
I can't seem to get to trace.axd. I have turned tracing on in web.config. Here is how I currently have i configured: <trace enabled="true" requestLimit="10" pageOutput="false"...
2
by: Bruce Russell | last post by:
This may sound stupid but I can't rename the WebForm1.aspx in the solution explorer. The file is located in my local web server at C:\Inetpub\wwwroot\Lab3-VB-Starter\WebForm1.aspx Is there...
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: Control Freq | last post by:
Hi, Confused about loading a pdf file into an iframe from C# code behind. I have a PDF file called temp2.pdf in my document root. The file is physically located at...
3
by: shardy | last post by:
Hello, I am trying to create a code repository for myself and am having trouble linking to files. Basically, the web server computer has drives from several other computers nfs mounted to it --...
1
by: tanya.wang | last post by:
I want to access files from a remote server so I mapped it in my server under z:\ for \\myserver\web\mysite\images\ I added this UNC path to my IIS virtual directory and name it as "upload" but I...
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: 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: 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
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...
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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.