The scope of the feature is Web.
SPWeb site = (SPWeb)properties.Feature.Parent; site.AllowUnsafeUpdates = true; // Set the Web Application's default error page SPSite siteCollection = new SPSite(site.Url); SPWebApplication webApplication = siteCollection.WebApplication; webApplication.FileNotFoundPage = "somepage.html"; webApplication.Update(); site.AllowUnsafeUpdates = false;
When it hits the line
webApplication.FileNotFoundPage = "somepage.html"; I get hit with
Access Denied. This code is within a
RunWithElevantedPrivileges delegate. If I run similar code from a console application from Visual Studio, it works fine.
How can I elevate privileges enough to update the web application settings? I've tried scoping it at Site and Web Application to try, and they didn't work.