| |

VerySource

 Forgot password?
 Register
Search
View: 1123|Reply: 9

About reporting an error when creating a folder on the server

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-16 20:00:01
| Show all posts |Read mode
Have a question about creating a folder to ask a master

C# code:
DirectoryInfo di=Directory.CreateDirectory(@"C:\Inetpub\wwwroot\Public\Html");

Error:

Server error in the "/NewsType" application.
-------------------------------------------------- ------------------------------

Access to the path "C:\Inetpub\wwwroot\Public\Html" is denied.
Explanation: During the execution of the current web request, an unhandled exception occurred. Please check the stack trace for details about the error and the source of the error in the code.

Exception details: System.UnauthorizedAccessException: Access to the path "C:\Inetpub\wwwroot\Public\Html" is denied.

ASP.NET is not authorized to access the requested resource. Please consider granting ASP.NET request ID access to this resource. ASP.NET has a base process identifier that is used when the application is not emulated (usually {MACHINE}\ASPNET on IIS 5, and network service on IIS 6). If the application is impersonating via <identity impersonate="true"/>, the identity will be an anonymous user (usually IUSR_MACHINENAME) or an authenticated requesting user.

To grant ASP.NET write access to a file, right-click the file in Explorer, select "Properties", and then select the "Security" tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account and check the box corresponding to the required access permissions.

Source error:


Line 21: {
Line 22: // Place user code here to initialize the page
Line 23: DirectoryInfo di=Directory.CreateDirectory(@"C:\Inetpub\wwwroot\Public\Html");
Line 24: //di.Create();
Line 25: Response.Write(di.Parent.Name);


Source file: c:\inetpub\wwwroot\newstype\webform2.aspx.cs Line: 23

Stack trace:


[UnauthorizedAccessException: Access to the path "C:\Inetpub\wwwroot\Public\Html" 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
   NewsType.WebForm2.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\newstype\webform2.aspx.cs:23
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-12-16 20:15:01
| Show all posts
No permission, just set the permission
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-12-16 21:15:01
| Show all posts
Html permission is set to be writable by ASPNET (iis5) or network service (iis6)
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-17 06:00:01
| Show all posts
It's obvious! Insufficient permissions!
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-12-17 09:45:01
| Show all posts
How to change it? Can it be achieved with C# statements? How to write it?
Reply

Use magic Report

0

Threads

21

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-17 10:00:01
| Show all posts
It is impossible for the virtual host to give the network service account the write permission to the c drive
Reply

Use magic Report

0

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-12-17 10:30:01
| Show all posts
Permission problem, set it up, right-click the folder ——> Permission ——> add Everyone and Internet guest accounts to set full control
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 United States

 Author| Post time: 2020-12-17 16:30:01
| Show all posts
Whose authority is set?
Public folder and Html folder?
That's a new one. If you want to change it, you can only change it with a sentence, right?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Morocco

Post time: 2020-12-18 11:30:01
| Show all posts
What is changed is the parent directory of the folder you created. You can add permissions on iis. Or just add permissions to that parent directory.
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-12-20 14:15:01
| Show all posts
The permissions of the parent folder are set, and the error report is the newly created folder
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list