Thursday, November 6, 2008

Access to the path is denied error for ASP Page on Windows 2003 Server

An ASP Page on a 2003 server got an Access to the path is denied when it tried to write to a file. I gave user ASPNET write permission, but that didn't solve the problem.

I posted this code as a Page named identity.aspx in the troubled directory. It seemed that the identity of the ASP user was
NT AUTHORITY\NETWORK SERVICE

In IIs, I navigated to the particular Web Site, and then to the directory. I right clicked on the folder and then selected PERMISSIONS > ADVANCED > ADD > ADVANCED > FIND NOW. I added NETWORK SERVICE as a user and then provided write access. That solved the problem.

- - -

identity.aspx

<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>

###

www.COMPUTERCRAFT.com

No comments: