0
votes

I have a scenario like create a file from database table data and uploading it to the server. i written a code for this it's working fine locally after hosted this application in IIS it's giving error like this .

Access to the path 'C:\windows\system32\config\systemprofile' 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:\windows\system32\config\systemprofile' 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 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , 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 File 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.

Can any one please help me how to resolve this error.

1
What are you actually trying to do here? It sounds like you are talking to the "user" directory (AppData, etc) on the web-server; if so... why? what are you trying to do in there, that you couldn't do just as easily in a temp file in the temp directory?Marc Gravell♦
@MarcGravell i'm using the following code but it still giving the same error after hosting in IIS ` string path = Path.GetTempPath(); path=Path.Combine(path, "file.tsv");`Muralikrishna
as per stackoverflow.com/q/16679571/23354, it sounds like you're simply using an IIS app-pool identity that is in the administrator group; if that is correct, then simply: don't do that.Marc Gravell♦
Simple guess, your app_pool identity's Temp path isn't set thus defaulting to c:\windows\system32. Have you tried to write in a local folder (app_data or so) ?xum59
@xum59 i was able to write a file in that path but while uploading it giving the above mentioned error..Muralikrishna

1 Answers

0
votes

Check IIS_User permissions to provided address. One non secure way is to give all permissions to every one. but be aware this is non secure way. try to manage IIS_User permissions using yourFolder/Properties/Security tab