0
    public class UploadHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
        ...

        // Create the directory if needed...
        if (!Directory.Exists(uploadDir))
        {
            System.Security.AccessControl.DirectorySecurity ds = new System.Security.AccessControl.DirectorySecurity(RivWorks.AppSettings.UploadRoot, System.Security.AccessControl.AccessControlSections.All);
            Directory.CreateDirectory(uploadDir, ds);
        }
        ...
    }

I have the above snippet of code for a ASHX file and it works fine in my local environment. As soon as I push it to a server environment I don't get an error, it appears to have built the directory, yet when I check for it - well - it is not there. When I run it via a FLEX app we are getting this error:

Error #2038: File I/O Error. URL: http://[ourdomain].com/UploadHandler.ashx?CompanyID=d229cc80-ca96-4a8a-992c-80c94ac2c6b4

Is there anything I am missing?

UPDATE:

  1. I can create files anywhere on disk
  2. I cannot create directories anywhere on disk.

I get this error now when trying to create a directory:

The process does not possess the 'SeSecurityPrivilege' privilege which is required for this operation.

2
  • make sure the folder isn't being created in the same folder (or a sub folder) as your website. This will cause application restarts. Commented Aug 31, 2009 at 21:16
  • ok. but if they are created outside the bounds of the website, how does one deliver the content to the web? A lot of widgets depend on the correct image path(s) to do their work and most are not in ASP.NET (Flex, Flash, etc). Commented Aug 31, 2009 at 21:29

3 Answers 3

2

Have you checked that your program has the correct access rights to the relevant directories on the server?

If you don't have the right permissions either because the account you are using is restricted or the directories are locked down you will see this error.

Sign up to request clarification or add additional context in comments.

7 Comments

ASP.NET account - Full rights, IUSR_machineName - Full rights, NETWORK SERVICE - Full rights. Am I missing any accounts?
mayurthakor.wordpress.com/2009/01/05/… - And I am doing this through Windows Explorer, right-click, properties/security....
and we can keep bumping up the Votes BUT my problem is not fixed.
This is not the correct answer unfortunately. While it is the typical answer it does not fix my problem. My problem has something to do with GPO and elevating the IIS account - which opens us up for a broader surface area of attack.
Ended up twiddling with the App Pool identity and got it running.
|
0

Is the site runs with identity impersonation=true? If so it runs under your credentials/authorization in your environment

Comments

0

Just simple use mkdir() function to create directory. to define a path you may use SERVERMAPPATH attribute.

use within try catch endtry block to avoid already existing or any other Error.

1 Comment

Welcome to Stack Overflow! This question was asked and successfully answered nearly three years ago. Answering recently asked questions, and questions have don't have an accepted answer is usually more helpful.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.