Server Error in Photos Application

G

Guest

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.
 
K

Kevin Spencer

Hi Ross,

I'm not sure what you don't understand, so forgive me if I tell you anything
you already know.

Every application running on an Operating System is called a process. If you
look in Task Manager, you can see all the processes running on your machine.
If you've never looked before, it can be quite enlightening to find out how
many processes are running on your machine when you have no programs running
at all. That is because services are processes too. They just run in the
background.

Every process that runs on your machine runs under the context of a User
account on your machine or domain. The User account determines what rights
that process has to access resources, such as the file sytem, on your
machine or domain. That should make clear the part of the message which
reads:
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

In case it is NOT clear to you now, I'll explain. The "process identity" is
the User account under which ASP.Net runs. Typically, it is a machine
identity or account, with the name "ASPNET" (on IIS) or "Network Service" on
IIS 6. It can be any account you specify in the machine.config file of the
machine.

By default, that User account has very limited permissions, as a security
measure. You can grant that user any permissions it needs if you are an
Administrator on your machine or domain.

In this case, the missing permission is:
[UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\Photos\Relatives" is denied.]

IOW, your ASP.Net process identity doesn't have permission to create a
directory under that path.

Solution: Grant the ASP.Net process identity (User account) the permission
it needs to create the folder.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

ASP.Net is a process which runs on your machine as well.
Ross said:
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.
 
G

Guest

Hi Kevin

Thanks very muchly - I shall give it a try - thanks for the really
good/clear explanation I really appreciate it.

You're bloods worth bottling.

Kind regards

Ross

Kevin Spencer said:
Hi Ross,

I'm not sure what you don't understand, so forgive me if I tell you anything
you already know.

Every application running on an Operating System is called a process. If you
look in Task Manager, you can see all the processes running on your machine.
If you've never looked before, it can be quite enlightening to find out how
many processes are running on your machine when you have no programs running
at all. That is because services are processes too. They just run in the
background.

Every process that runs on your machine runs under the context of a User
account on your machine or domain. The User account determines what rights
that process has to access resources, such as the file sytem, on your
machine or domain. That should make clear the part of the message which
reads:
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

In case it is NOT clear to you now, I'll explain. The "process identity" is
the User account under which ASP.Net runs. Typically, it is a machine
identity or account, with the name "ASPNET" (on IIS) or "Network Service" on
IIS 6. It can be any account you specify in the machine.config file of the
machine.

By default, that User account has very limited permissions, as a security
measure. You can grant that user any permissions it needs if you are an
Administrator on your machine or domain.

In this case, the missing permission is:
[UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\Photos\Relatives" is denied.]

IOW, your ASP.Net process identity doesn't have permission to create a
directory under that path.

Solution: Grant the ASP.Net process identity (User account) the permission
it needs to create the folder.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

ASP.Net is a process which runs on your machine as well.
Ross said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top