Server Error in Photos Application

From: Ross (Ross_at_discussions.microsoft.com)
Date: 10/28/04


Date: Thu, 28 Oct 2004 12:55:06 -0700

Hi

I have an application using asp.net that I am running on my PC.

The web form has a text box where you can enter a name for a new Photo
category then click on the button.

The code is intended to create a new directory under Photos such as
"Relatives".

However, I am getting the following error message in IE (between the two
rows of @@@@:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Server Error in '/Photos' Application.
________________________________________
Access to the path "c:\inetpub\wwwroot\Photos\Relatives" is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\Photos\Relatives" is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
appropriate user or group. Highlight the ASP.NET account, and check the boxes
for the desired access.

Source Error:

Line 38: strAppRoot = Server.MapPath("/Photos")
Line 39: strNewFolder = strAppRoot & "\" & strName
Line 40: Directory.CreateDirectory(strNewFolder)
Line 41: End Sub
Line 42:

Source File: c:\inetpub\wwwroot\photos\category.aspx Line: 40

Stack Trace:

[UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\Photos\Relatives" is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
   System.IO.Directory.InternalCreateDirectory(String fullPath, String path)
+632
   System.IO.Directory.CreateDirectory(String path) +195
   ASP.category_aspx.CreateNewCategory(String strName) in
c:\inetpub\wwwroot\photos\category.aspx:40
   ASP.category_aspx.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\photos\category.aspx:45
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750

________________________________________
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

I have tried the tips in the above message, but to no avail. It is true to
say that I do not have a clear understanding of the part of the msg that says:

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

So, if somebody could give me a hand I would appreciate it.

-- 
Kind regards
Ross Petersen

Loading