ASP.NET Getting the Error "Access to the Path Is Denied." While Trying to Upload Files to My Windows Server 2008 R2 Web Server

ASP.net Getting the error Access to the path is denied. while trying to upload files to my Windows Server 2008 R2 Web server

Your asp.net account {MACHINE}\ASPNET does not have write access to that location. That is the reason why its failing.

Consider granting access rights to the resource to the ASP.NET request identity.

Right click on downloading folder Properties > Security Tab > Edit > Add > locations > choose your local machine > click OK > Type ASPNET below "Enter the object name to select" > Click Check Names
Check the boxes for the desired access (Full Control). If it will not work for you do the same with Network Service

Now this should show your local {MACHINENAME}\ASPNET account, then you set the write permission to this account.

Otherwise if the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.


Or just use dedicated location for storing files in ASP.NET which is App_Data. To create it right click on your ASP.NET Project (in Visual Studio) Add > Add ASP.NET Folder > App_Data. Then you'll be able to save data to this location:

var path = Server.MapPath("~/App_Data/file.txt");
System.IO.File.WriteAllText(path, "Hello World");

access to the path is denied asp.net in iis

Generally the user account the application pool runs under will not have permissions to write to any sub-folders for security reasons. You will have to check which user your application runs under and then give that user write permissions to the SpeechFile folder. Make sure that is the only folder that you do give it write permissions to so that the security risk is minimised.



Related Topics



Leave a reply



Submit