views:

317

answers:

1

Hi guys,

I am trying to save an image file in a custom module I am building for a DNN site.

However when I run the code I get an UnauthorizedAccessException.

if(upLoadAddImg.HasFile)
            {
                String imageLocation = ConfigurationManager.AppSettings["ImageFolderPath"];

            //Upload file 

            upLoadAddImg.SaveAs(Server.MapPath(imageLocation));

}

I am running on localhost using the internal visual studio server. Tthe folderpath is all right and I have made sure Network Service has full permissions.

Am I missing something obvious or does DNN have some special permission setting I am missing?

A: 

If you are using the dev server in VS its identity is not Network Service by default. Most likely the directory you are saving to loccally is not allowed for the aspnet user - if you run this on a web site it should work at least code wise -------

To test it you can do one of two things make the portal directory open to everyone or set up a local site not run on the dev server ----

codemypantsoff