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(
"%Filename%.aspx",
UTF8Encoding.UTF8.GetBytes(%PageMarkupAsString%));
}
}
Test user 100% has "contributor" rights for test library.