473,847 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9302
This is my source code:

<%@ Import Namespace="Syst em.IO" %>
<%@ Import Namespace="Syst em"%>
<html>
<head><title>Wr ite to file</title>
</head>
<body>
<%
Dim txtWriter As StreamWriter
txtWriter = File.CreateText (Server.MapPath ("Hello.txt" ))
txtWriter = New StreamWriter("H ello.txt")
txtWriter.Write Line("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******@discu ssions.microsof t.com> wrote in message
news:30******** *************** ***********@mic rosoft.com...
This is my source code:

<%@ Import Namespace="Syst em.IO" %>
<%@ Import Namespace="Syst em"%>
<html>
<head><title>Wr ite to file</title>
</head>
<body>
<%
Dim txtWriter As StreamWriter
txtWriter = File.CreateText (Server.MapPath ("Hello.txt" ))
txtWriter = New StreamWriter("H ello.txt")
txtWriter.Write Line("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******@discu ssions.microsof t.com> wrote in message
news:30******** *************** ***********@mic rosoft.com...
This is my source code:

<%@ Import Namespace="Syst em.IO" %>
<%@ Import Namespace="Syst em"%>
<html>
<head><title>Wr ite to file</title>
</head>
<body>
<%
Dim txtWriter As StreamWriter
txtWriter = File.CreateText (Server.MapPath ("Hello.txt" ))
txtWriter = New StreamWriter("H ello.txt")
txtWriter.Write Line("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\wwwr oot\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>\A SPNET 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******@discu ssions.microsof t.com> wrote in message
news:B2******** *************** ***********@mic rosoft.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******@discu ssions.microsof t.com> wrote in message
news:30******** *************** ***********@mic rosoft.com...
> This is my source code:
>
> <%@ Import Namespace="Syst em.IO" %>
> <%@ Import Namespace="Syst em"%>
> <html>
> <head><title>Wr ite to file</title>
> </head>
> <body>
> <%
> Dim txtWriter As StreamWriter
> txtWriter = File.CreateText (Server.MapPath ("Hello.txt" ))
> txtWriter = New StreamWriter("H ello.txt")
> txtWriter.Write Line("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\wwwr oot\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>\A SPNET 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******@discu ssions.microsof t.com> wrote in message
news:B2******** *************** ***********@mic rosoft.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******@discu ssions.microsof t.com> wrote in message
news:30******** *************** ***********@mic rosoft.com...
> This is my source code:
>
> <%@ Import Namespace="Syst em.IO" %>
> <%@ Import Namespace="Syst em"%>
> <html>
> <head><title>Wr ite to file</title>
> </head>
> <body>
> <%
> Dim txtWriter As StreamWriter
> txtWriter = File.CreateText (Server.MapPath ("Hello.txt" ))
> txtWriter = New StreamWriter("H ello.txt")
> txtWriter.Write Line("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
5486
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
0
1776
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 web project even cannot create a new one. The message for create a new web project is: (Open an oldASP project got similar error.) My system is Windows 2000 Server ---------------------- The default web access mode for this project is set to...
4
3259
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 web project even cannot create a new one. The message for create a new web project is: (Open an oldASP project got similar error.) My system is Windows 2000 Server ---------------------- The default web access mode for this project is set to...
9
4450
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" traceMode="SortByTime" localOnly="false" />
2
2969
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 some configuration problem in my IIS setup? Thanks,
3
7974
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 do I need to do?
1
6115
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 C:\inetpub\wwwroot\MySite\temp2.pdf . In the code behind I try: Iframe1.Attributes.Add("src", "\\MySite\\temp2.pdf"); // THIS WORKS Iframe1.Attributes.Add("src",
3
3504
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 -- and I want to link to a file (just a .C file) on one of the nfs mounted drives. I'm an html novice and have tried: <p><a href="/home/nfs_drive_mount_point/dir/script.C">script.C</a></p>
1
9088
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 still cannot use any FSO to read it. Here is my code: <% Dim fs set fs=Server.CreateObject("Scripting.FileSystemObject")
0
9879
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 usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10643
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10705
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5716
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5907
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4113
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.