"Access Is Denied" Error is Thrown When Trying To Create A New Directory

I have a requirement to search for the existence of a directory (a specifice Company Name) that is beneath the application root. (C:\inetpub\wwwroot\MyWebApp\Documents\"CompanyName") and create it if it does not already exist. Where "CompanyName is the value held in the session variable, Session("curUser.nFacilityUid")


I'm using the following code to check for the existence (and creation, if necessary) of a directory, but an execption is thrown each time I attempt to create a directory. The error message states "Access to the path "c:inetpubwwwrootmywebappdocuments@companyname is denied". Would anyone be able to help me understand what is going on?

I have the following set in my web.config file:
<authentication mode="None" /> 
 
<code>

Dim strPath As String
'Session("curUser.nFacilityUid") is the name of the directory
strPath = Server.MapPath("\MyWebApp\Documents\" & Session("curUser.nFacilityUid"))

Dim dir As New DirectoryInfo(strPath)

If dir.Exists Then
'List it's contents

Else

    Try

    'Create the directory
   dir.Create()

    Catch ex As Exception
        ShowMessage(ex.Message)

    End Try

End If



</code>

Thanks,
Kevin
0
klowery
9/25/2005 9:17:13 PM
asp.net.security 27051 articles. 1 followers. Follow

5 Replies
1160 Views

Similar Articles

[PageSpeed] 8

You need to grant the ASPNET local account write access (Windows
Explorer, Right-Click, Properties, Security...) to your
MyWebApp\Documents directory.

If you are using IIS 6.0, you need to grant write rights to that directory for the IIS_WPG local account group.

Hope that helps,
Wim


Wim Hollebrandse
---
http://www.zealandit.com
0
WimH
9/25/2005 9:53:41 PM

Wim:

Thanks for your reply. I am running IIS 6.0 and Windows XP Pro on my workstation. I have two questions, though.

1) When I attempt to grant the ASPNET local account write access to MyWebApp\Documents directory by right-clicking on the Documents folder, my properties dialog box contains four tabs:

General
Sharing
Web Sharing
Customize

The only options I have on the Sharing tab are "Local Sharing and Security", "Network Sharing and Security", and the link "View your Windows Firewall Settings".

I can't seem to discover where to grant my ASPNET local account write access. If I check "Share this folder on the network" and check "Allow Network Users to Change My Files" I am able to create a directory (but I don't think I want to share this folder on the network, do I?). Is this what you were talking about?

2) Where might I grant write rights to the Documents directory for the IIS_WPG local account group? I have the following tabs available to me when I open IIS, right-click on the Documents directory under my web application directory:
Directory
Documents
Directory Security
HTTP Headers
Custom Errors

When I click the "Edit" button in the Directory Security tab, the "Authentication Methods" dialog has "Anonymous access" checked and the account listed in the "User Name" text box is IUSR_ASPNET and "Allow IIS to control password" is checked. Is this what you were talking about regarding the granting of rights to the Documents directory?

Any inputs are greatly appreciated.

Thanks,
Kevin

0
klowery
9/26/2005 6:56:22 PM
Kevin,

If you're running Windows XP Pro, you can't be running IIS 6.0, you'll be running IIS 5.1.

You need to enable the security tab in Windows XP Pro first. It's disabled by default. To enable it, open any Windows Explorer window, go to Tools, Folder Options, View, and in the list of Advanced Settings untick 'Use Simple File Sharing'.

Now, simply go to the Properties of your folder MyWebApp\Documents in Windows Explorer, and add the ASPNET local account and grant the account write permissions to your directory.

That's all there is to it. No need to configure anything in IIS.

Hope that helps.
Wim

Wim Hollebrandse
---
http://www.zealandit.com
0
WimH
9/26/2005 9:30:40 PM
Wim:

Many thanks! You have solved my problem. I can now write to my "Documents" directory from my web application.


My mistake on my version of IIS (sorry about that). You are correct, I am running IIS 5.1. 



0
klowery
9/26/2005 10:46:41 PM

Cor. I wish it were that easy! I'm not trying to make directories or files, just reading them would be grand!!

I have set ASPNET machine account to both the web application directory and virtual host webservice but have been consistently getting a 401 error with the following Stack Trace output:

[WebException: The request failed with HTTP status 401: Unauthorized.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +1304
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +218
   LPGOpsWeb.localhost_Orders.ServiceOrders.OrdersUnprocessed()
   LPGOpsWeb.ViewOrdersUnprocessed.Display()
   LPGOpsWeb.ViewOrdersUnprocessed.btnRefresh_Click(Object sender, EventArgs e)
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292


I figured at first that the .net account needed permissions on the webapp dir, but nothing I am doing in regards to permissions both on IIS webservices and application directories appears to be making any difference? I just can't get the data to show up...Thoughts anyone?

Thanks
0
motormouth
9/27/2005 11:59:19 PM
Reply:

Similar Artilces:

creating a new tableAdapter, I get error message "Access is denied"
I copied my .mdf database from a file and pasted it into the visual studio project App_Data folder.I can see the tables and the columns etc when creating my TableAdapter, and create my sql query etc, but then when I hit the finish button, I get this error "an Unexpected Error has Occured\nError Message: Access Denied". Anyone know why I can't create my TableAdapter?  Looks like, but not positive as a permission problem on the access database. Make sure you have all rights in that folder as well as the user running IIS.CheersAlMy BlogMapStats.NETPlease click on '...

Error found "Access to the path "C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Viewers" is denied. "
Hi guys! i'm trying to solve the error "Err Msg: "Object reference not set to an instance of an object" in ASP.NET app" but when i followed the instructions in the http://community.crystaldecisions.com/library/kbase/articles/c2011144.asp link, this error appeared ""Access to the path "C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Viewers" is denied. " What's going on? i already went to the iis to add new virtual directory (CrystalReportWebFormViewer) but different error appeared when i compile and browse my application. pls help ...

I am trying to run a login sample, so in "Web Site Administration Tool" i clicked "Use the security Setup Wizard to configure security step by step." and got this famous error: An error was encountere
After this i have the lengthy description of the rror The following message may help in diagnosing the problem: Specified argument was out of the range of valid values. Parameter name: site at System.Web.Configuration.WebConfigurationHost.InitForConfiguration(String& locationSubPath, String& configPath, String& locationConfigPath, IInternalConfigRoot configRoot, Object[] hostInitConfigurationParams) at System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object[] hostInitConfigurationParams) at System.Configuration.Internal.InternalConfigConfigur...

Difference between "Creating new website" and "Creating new web project"
Hello (Using VS2008) I would like to know the difference between "Creating a New Website" and "Creating a New Web project". Thanks a lot. Hi, the first one creates a web site using the web site project model (default in VS2005) which is based on that you don't have a standalone project file, but project contents are defined by physical directory structure. Basically a web site project has also slightly different compilation model, for example not everything in the project is necessarily built into single assembly, and you don't necessarily ha...

Security Trimming / "Access is denied" error
Hi All  I have an issue where I have enabled security trimming of my menu. If my files are at the root or I secure a whole folder I have no issue, but if I try to secure individual files within a folder other than the root, when clicking the links I either have an access denied issue (even though the user has been assigned the relevant role) OR the menu path is not trimmed and links are still visible and accessible (even when role is removed). I have a webconfig file in the root as well as in the folder where the files are.  If I have this in my webconfig file in t...

Error trying to create a new user. "An error occurred. Please contact the site administrator."
Finally got the thing to work. However, when trying to add a new user, after successfully filling out all fields including acceptable password, I get the following message: An error occurred. Please contact the site administrator. What to do? Fixed this by changing the default database to ASPNETDB and copying the table from Classifieds there. Also had to give the default account full permissions on everything....

How to automatically send denied users to "access denied" page, instead of a login prompt only then to be sent to "access denied" page
Hello: My security works fine except for one small annoyance.  This is an intranet site only and are using Windows (AD) authentication with Anonymous turned off.  The 'good' users get right in, with no prompts.  This is good.  However, the 'bad' (denied) users get a prompt to enter their credentials only to be denied.  I would like to eliminate the need for them to even try and enter credentials and send them directly to an "access denied" page (no prompts).  It only wastes their time and aggrevates them. Thoughts? Tha...

"Access to the path is denied" when trying to create folder...
I'm trying to create a directory... if (!System.IO.Directory.Exists("~/Pdf/" + ds.Tables[0].Rows[0]["Name"].ToString())) System.IO.Directory.CreateDirectory("~/Pdf/" + ds.Tables[0].Rows[0]["Name"].ToString());..but get the following error: 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.UnauthorizedAccessExcept...

ERROR: "The directory does not exist or is not accessible because of security settings"
OK, I am about to lose my mind on this one...I have an ASP.NET application that was devloped on Windows XP SP2, IIS 5.1 and .NET Framework v1.1.4322.  On the development server, this is running fine.I migrated the app using simple file copy to a Windows 2003 Web Edition Server, IIS 6.0 and .NET Framework v1.1.4322.  When I tried to run this app, I get an error (full text is below this post.The error seems to indicate a permissions problem.  I have checked the permissions on every directory microsoft reccomends, including the the application directory tree up to the root o...

"access to path"...."is denied"
I have a program that opens a csv file and copies all records to a database.  its working fine in development system but when i deploy this to the live system and if i try to copy a csv file on my machine i am getting an error "access to path"..<tempfile.txt> .."is denied.  I am creating a temporary file on the live server and then changing data and then copying records from the temp file to the live databaseThe problem is that the program cannot access the temp file.  Is there a way to change security access rights of the temp file programmatically so tha...

"An error occurred saving the project file"PortalVBVS.vbproj". Access is denied."
"An error occurred saving the project file"PortalVBVS.vbproj". Access is denied." I have been getting this error msg all the time, anytime I update one of the files. Has anybody seen this error besides me. It been so frusrating I built a complete new system from scratch, and I'm still recieve this msg. I believe that it may be related to one of MS service packs, but It has made my portal useless. Any help would be greatly appreciated, thanks. OS 2000pro with VS2002 aghPeter Nagy Obvious question: do you have write permissions on the Folder? Are any files Read Onl...

Unknown Error "-1". when trying to create new website
When I open up VWD an choose to create a new Website, I receive an error message:  Unknown Error "-1". I can create a new file without an error.   I can also open an existing Website without receiving the error.  Any suggestions? This is my first time using this product, so I am at a little bit of a loss.  Thanks!     I've not run into this error before.  Does it happen when creating a IIS website such as http://localhost/MyWeb or an isolated disk based website such as c:\MyProjects\MyWeb ? A couple of things to check, if you're...

"Access to report file denied" error trying to gnerate a PDF
I am getting the following error when trying to generate a PDF using Crystal Reports from a web application: Exception Details: System.Runtime.InteropServices.COMException: Error in File C:\WINDOWS\TEMP\...filename.rpt: Access to report file denied. Another program may be using it.  I everything I have researched points to following the advice: http://blogs.aspadvice.com/rjdudley/archive/2005/03/14/3058.aspx I followed the instructions but am still getting the “access to report file denied” error.  The web application is using...

Creating the local user account "General access denied error"
 Hi,i want to create the local user account, the script I am using for this is as follows, Dim computer As String = "PBAD-FTP" Dim account = GetObject("WinNT://" + computer + ",Computer") account = account.Create("user", username) account.SetPassword("secret") account.SetInfo()when i run that code from the ASP.net it work succesfully and create the user. but after I publish this on IIS and try same it give me the "General access denied error" and the source for this is ActiveDirectory. I try to set permission for Inter...

Web resources about - "Access Is Denied" Error is Thrown When Trying To Create A New Directory - asp.net.security

Resources last updated: 12/1/2015 3:29:36 PM