Click here to Skip to main content
15,885,029 members
Please Sign up or sign in to vote.
1.82/5 (3 votes)
See more:
Hello,

i just deployed a webapp, and am getting the error below. The webapp needs to write to files in the app_data, and am being denied access.

i checked the permission of the webapp virtual directory, and i have all necessary access (read/write) for all users

Can you explain what could be causing the error?
could it be code bug?

thanks

D:\InetPub\vhosts\mysite.com\httpdocs\LicService\App_Data

Server Error in '/LicenseService' Application.
Access to the path 'E:\InetPub\vhosts\mysite.com\httpdocs\Service\App_Data' 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 'E:\InetPub\vhosts\mysite.com\httpdocs\Service\App_Data' 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 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: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Stack Trace: 

[UnauthorizedAccessException: Access to the path 'E:\InetPub\vhosts\mysite.com\httpdocs\Service\App_Data' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7716339
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +64
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +77
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54
System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +74
System.Threading.CompressedStack.runTryCode(Object userData) +70
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) +108
System.Xml.XmlTextReaderImpl.OpenUrl() +186
System.Xml.XmlTextReaderImpl.Read() +208
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +112
System.Xml.XmlDocument.Load(XmlReader reader) +108
System.Xml.XmlDocument.Load(String filename) +87
LicService.install.cmbSettingFiles_SelectedIndexChanged(Object sender, EventArgs e) in install.aspx.vb:72
LicService.install.Page_Load(Object sender, EventArgs e) in install.aspx.vb:15
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Posted
Updated 7-Sep-21 19:00pm
Comments
Mohamed Mitwalli 23-Apr-12 3:06am    
Hi ,
Are you sure you give IIS user full control ??
Cool Smith 23-Apr-12 3:45am    
yes, i have full control for all users in my control panel virtual directory
Sandeep Mewara 23-Apr-12 3:08am    
Just confirming, though you said all the permissions are already in place, is the following done:
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.

Looks like we are missing some permission somewhere.
Cool Smith 23-Apr-12 3:42am    
i have full permission for all users as i mentioned ealier
Herman<T>.Instance 23-Apr-12 4:01am    
which users?
is 'Network service' added to e:\inetpub and all (sub)folders?

Instead of granting permissions to ASPNET user, grant permissions to NETWORK SERVICE user. Modify permissions within the folder should be enough, no need to give full permissions (no reason to give more permissions than needed)
 
Share this answer
 
Comments
[no name] 3-Sep-13 11:18am    
Solution 2 works fine for me. thanks Fadao
Saman With You 16-Oct-16 10:32am    
Worked for me too. thanks.
Member 14362033 1-Dec-20 5:00am    
Yes it worked for me too . Thank you
Please login as administrator and add user

IIS AppPool\DefaultAppPool

and give full permission.

Also check your firewall.
 
Share this answer
 
Based on the users listed, try:

Add ASPNET user as it might be that ASP.NET is not authorized to access the requested resource. If no impersonation then allow ASPNET user access on that folder Or else if impersonation in Web.config then give access to the impersonated user.
 
Share this answer
 
Comments
Cool Smith 23-Apr-12 14:48pm    
how can i use impersonation, note that its a webhost not on my computer
Sandeep Mewara 23-Apr-12 15:56pm    
In your Web.Config, enable impersonation and then you need to provide access to the impersonated user. But, before this Iwould suggest you to get some access on the host computer as you are trying to deploy on it. As long as you dont have admin rights or so, oit would be really difficult to configure your system properly.
Cool Smith 23-Apr-12 16:51pm    
does asp.net need admin rights on the web server to run?
Sandeep Mewara 23-Apr-12 16:53pm    
No. But you might need it to configure the website on webserver.
Cool Smith 23-Apr-12 18:23pm    
hello, i have the following users which all have read write access. is there some way to set the user to use in my webapp?

Administrators
SYSTEM
myHost Domain User (myUserName)
myHost IIS User (IUSR_myUserName)
myHost IIS WP User (IWPD_122(myUserName))
For Access Denied Error in IIS server for particular file , please follow the below steps

1- Goto to C:\inetpub\wwwroot\YourVirtualDirectortName\toFolderpathWhereFileIsPresent

2- Right click on your file -> Properties -> Pop Up of User properties appears -> click on Security tab-> click on Edit -> select IIS_IUSRS-> tick on Allow Full Control -> Click Ok

This will surely solve the Access denied problem
 
Share this answer
 
Comments
CHill60 27-May-14 12:15pm    
Apart from the fact the question is over 2 years old, and is already adequately answered, unless the person following your steps had Admin access they will get the same problem. Also Allow Full Control - see Solution 2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900