467,119 Members | 744 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,119 developers. It's quick & easy.

Unable to write file from ASPX page. What am I missing?

I have a folder on \\webserver\wwwroot, called staticContent. The folder
has several message of the day text files, such as RepMotd.text. I have
an admin page, AdminMotd.aspx, that allows a user to view and edit the
contents of the files.

Webserver is running Win Server 2003 64-bit and IIS 6.0. The development
machine is Win XP, using Visual Studio 2005 (thus ASP.Net 2.0.)

In IIS, staticContent folder has Write checked and execute permission is
set to Script Only . In NTSF, the folder grants full permissions to
Network System.

When I try to overwrite an existing file in \staticContent, or try to
create a new file, I get a System.UnauthorizedAccessException. The
Application error log on \\webserver notes that the error is on the page
I am trying to run, that my user name is what I logged in as, that I am
authenticated, and that the thread account name is NT AUTHORITY\NETWORK
SYSTEM. Elsewhere, I am able to read these same files and insert them
dynamically into the web page.

This is the code that I am trying to run in AdminMotd.aspx, cut down to
the basics. If it makes any difference, the code is run "in page" and
not as part of a separate code-behind file.

<script runat="server">
Protected Sub MotdChange(ByVal ThisFile As String, ByVal ThisText As
Dim sw As StreamWriter = New StreamWriter(StaticRoot + ThisFile,
End Sub

Protected Sub RepMotdChange_Click(Byval sender As Object, ByVal e As
MotdChange("RepMotd.text", RepMotdText.Text)
End Sub

<asp:Content ...>
<asp:TextBox ID="RepMotdText" runat="server"></asp:TextBox>
<asp:Button ID="RepMotdChange" runat="server" />

I have traced that the error occurs when New StreamWriter is called,
rather than when actually trying to write to the file. Obviously I'm
missing something, but danged if I can find it. Any suggestions?
Gregory Gadow

Jul 13 '06 #1
  • viewed: 1923
1 Reply
There was no way for you to know it (except maybe by browsing through
of the previous questions before posting yours - always a recommended
practice), but this is a classic asp newsgroup.
ASP.Net is a different technology from classic ASP.
While you may be lucky enough to find a dotnet-savvy person here who
answer your question, you can eliminate the luck factor by posting your
question to a newsgroup where the dotnet-savvy people hang out. I

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by tshad | last post: by
2 posts views Thread by Seok Bee | last post: by
3 posts views Thread by Gregory Gadow | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.