1

I'm working on a website which uses ASP.NET and IIS 8.5.

The site is currently running on my dev machine (standard win 8.1 laptop) and I can browse in general around the site absolutely fine.

My problem comes when the user tries to save a file to a folder. I get the error: Access to the folder blah is denied

Having searched around the web I've found the solution to this is to grant write permissions on the folder to the user ASP.NET uses.

I've granted write permissions to the I_USERS group, the App Pool User and the Network Service, but this still hasn't solved the issue.

I've also seen that the user ASPNET must be added to the permissions too, however I don't seem to have that user on my machine. -Is this why I am getting the error, or is it something else completely?

Some Code:

Markup:

    <div class="col-sm-10" Style="float: left; padding-left: 10px;">
         <asp:FileUpload ID="FileUploader" style="width:100%" runat="server" CssClass="text" />
    </div>  

        /*****Some other controls (eg.textboxes) here *****/

    <div class="row">
        <div class="col-sm-12" style="margin-top:10px;">
            <asp:Button ID="uploadBTN" runat="server" CssClass="frbtn" OnClick="uploadBTN_Click" Text="Upload Video" Style="width: 20%; float: right;" />
        </div>
    </div>

Code Behind:

    protected void uploadBTN_Click(object sender, EventArgs e)
    {
        FileUploader.SaveAs(FRConfig.VideoFolder); //This bit does the saving
        Video v = new Video(FileUploader.FileName, fileDescripTB.Text);//This saves the video data to a database.
        Helpers.Show("Video Uploaded Successfully!"); //This launches an alert to state it has been sucessfully uploaded.
    }

Thank You

3
  • Could you add some code to your question to show how/where you are trying to save a file? May 24, 2015 at 17:27
  • Added, let me know if there's anything else I should add, I'm used to developing WPF apps so I'm not sure whats relevant when it comes to ASP.NET!
    – KidCode
    May 24, 2015 at 17:43
  • Where does "FRConfig.VideoFolder" point to? May 24, 2015 at 20:56

1 Answer 1

0

When using the IIS defaults, granting write permissions to IIS_IUSRS should be enough. The App Pool User is automatically a member of IIS_IUSRS, Network Service is only needed if you change the identity of the application pool.

The following aspx pages tests write permissions for the default web site:

<%@ Page Language="C#" debug="true"%>
<script runat="server">
   void Page_Load() {
      System.IO.File.Copy(@"C:\inetpub\wwwroot\iis-85.png",@"C:\inetpub\wwwroot\new.png",true);
   }
</script>

You should not allow write access to locations under your web root, place file uploads into a different directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.