Possible reasons for Directory.CreateDirectory throwing an UnauthorizedAccessException on a shared host

I am currently working on an ASP.NET 3.5 / IIS7 application for which I am using WinHost as a temporary hosting environment, I have some dramas with what I consider to be permission problems and the ticket sales process has just reached " you are on your own. "

Here is what I am trying to do:

var dir = Server.MapPath("~/MyFolder/NewPath"); Directory.CreateDirectory(dir); 

And here is the answer I get:

Access to the path 'E: \ web \ MyAccount \ MyFolder \ NewPath' 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 occurred in the code.

Exception Details: System.UnauthorizedAccessException: Access to path 'E: \ web \ MyAccount \ MyFolder \ NewPath' is denied.

The stack trace shows that the CreateDirectory line is not working. The application runs normally locally, and the identifier in which the application pool runs has write access to the "MyFolder" path. In both environments, the trust level is set to Full.

WinHost Guide:

By default, the asp.net user has full permissions to your site.

Looking further, WindowsIndentity.GetCurrent (). The name returns "W02 \ aspnet_17884", which appears to be account specific. I feel that this account does not have write access to the application file system, but when I called WinHost, I got this:

The problem you are facing is the configurations associated with your application.

and

What I recommend doing is registering and then asking in the DiscountASP.NET community forum

Obviously the question now is stack overflow :)

Can anyone suggest application level configuration changes? Most likely, is this a problem with permissions on the hosting site? Thanks.

Update: I also asked a question on the WinHost forum .

+4
source share
2 answers

And the answer ... deployment on the Internet broke it. Actually, the answer strictly consists in the fact that the permissions simply were not there (as expected), but the reason is that the web deployment somehow deleted the write permissions. I see this from the point of view of deploying on the Internet, having the ability to publish access control lists, but why WinHost allows this to manipulate the permissions of the directory containing the website outside of me.

Additional information on my question (and WinHost answer) is on their forum in the section No write access to the file system .

+4
source

Yes, "W02 \ aspnet_17884" must have sufficient permission to create the folder. I suggest you create a free account on ASPSPIDER and upload a very simple sample there with a configuration similar to yours. If this works, not on WinHost, you can show them how it works on aspspider, but not on your server. Then make them allow or get a new host.

0
source

Source: https://habr.com/ru/post/1333650/


All Articles