I faced with weird issue. I'm trying to add a new file to the library on button click event, everything is fine when site admin performs this action, but user with contributor permissions is getting access denied. Any thoughts how to fix this? I could not use elevating privileges because of missing "CreatedBy" field.

using (var site = new SPSite(SPContext.Current.Site.ID))
    using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
        var list = web.Lists[%ListGUID%]
        var folder = list.RootFolder;

        SPFile file = folder.Files.Add(                

Test user 100% has "contributor" rights for test library.

1 Answer 1


I found an answer here.

Users with contributor permissions are prevented from uploading files with the following extensions: ASPX; MASTER; XAP; SWF; JAR; ASMX; ASCX; XSN; XSF;

So my problem is in "aspx" extension of file I'm trying to create. This could be fixed by removing 'aspx' from WebApplication.WebFileExtensions collection.

Your Answer

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

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