Access to the path is denied -How to solve this problem in ASP.NET
System.UnauthorizedAccessException: Access to the path is denied. This problem occurs when you are going to use file system from an ASP.NET web application and definetely annoying .this article is also about use of identity tag in web.config file .
I designed an asp.net page to move a file from one folder to another as a part of my web application. Code written for page load event was
Dim path As String = "C:\AAQMS\AAQMS.html"
Dim dt As DateTime
dt = DateTime.Now
Dim dat As String
dat = dt.Day & "-" & dt.Month & "-" & dt.Year & "-" & dt.Hour
'Response.Write(dat)
Dim path2 As String = "C:\AAQMS1\AAQMS " & dat & ".html"
If File.Exists(path) = True Then
File.Move(path, path2)
Else
Response.Write("File doesn't Exist")
End If
If File.Exists(path) = True Then
File.Delete(path)
End If
I wanted to move file aaqms.html from C:\AAQMS to C:\AAQMS1 .This was running on my XP machine without any problem but when i transferred this application to my windows 2003 server i was facing this problem
Server Error in '/AAQMS-SERVER' Application.Access to the path 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 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 , 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.
I managed to find a solution that by giving access right for these folders to ASPNET user it will work
I provided full rights to ASPNET user by going to properties of the folder. Even i assigned full rights to user IUSR_MACHINENAME(anonymous user) but it didn't work.
The solution which worked in my case is
We can make our application run under another account than ASPNET in cases where.
We need access to the filesystem somewhere ASPNET doesn't have access. To
do this, we can insert the element in web.config like this:
if we simply write this line in web.config then it will run under IUSR_MACHINENAME account.
Happy Coding.
Nothing Found!
Why not submit your own content? Signup here.
-
Howto use QueryString in ASP.NET for passing info between pages | By rajeshchoudhary | in Web Development
The QueryString in ASP.NET is used to pass information between pages....
-
Custom error pages in asp.net using configuration file | By rajeshchoudhary | in Web Development
In ASP.NET you can handle page level errors using OnError method of page object or Application level errors using A...
-
Build A Free Ecommerce Store Front In Less Than An Hour | By AaronMeagher | in Web Development
Are you looking to start selling online and want a quick and easy solution for your ecommerce storefront? While yo...
-
Black Hat SEO Techniques | By ChandraK | in Web Development
Black hat SEO is a technique that is used to get higher ranking for the website in a base manner. Black hat SEO is ...
-
White Hat SEO Techniques | By ChandraK | in Web Development
White hat SEO is a method that follows all the required webmaster guidelines in effective building of the website. ...
-
Howto use QueryString in ASP.NET for passing info between pages | By rajeshchoudhary | in Web Development
The QueryString in ASP.NET is used to pass information between pages....
-
Custom error pages in asp.net using configuration file | By rajeshchoudhary | in Web Development
In ASP.NET you can handle page level errors using OnError method of page object or Application level errors using A...
-
Using remote desktop in windows XP | By rajeshchoudhary | in Computers
if you want to connect to a machine remotly using Remote Desktop Connection, remote Desktop in target machine needs...
-
setting password wisely for your accounts | By rajeshchoudhary | in Computers
Incidents of information phishing and hacking are happening every now and then. One fine day morning you wake up to...
-
Web.config –configuration file for ASP.NET web application. | By rajeshchoudhary | in Web Development
This article tells what web.config file is, how to write this and how this file is used by run time to apply settin...








No comments yet.