423,867 Members | 3,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,867 IT Pros & Developers. It's quick & easy.

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

P: n/a

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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.