SharePoint2013

How to properly use SPWeb.AllowUnsafeUpdates?

At times you may need to allow unsafe updates for SPWeb objects to get your code to run. This, in SharePoint’s C# full-trust code, is done by setting SPWeb.AllowUnsafeUpdates to true. However, as this is an exception to security settings, you should generally avoid it. When you can’t, it’s a good practice to limit the change to as small a scope as possible. This is true even though the setting is only persisted for the duration of the request (unless the SPWeb object was gotten…Continue reading How to properly use SPWeb.AllowUnsafeUpdates?

File not found

“File not found”-error when trying to activate custom feature on SharePoint

This post is about fixing on of the most non-spesific errors you can get when activating features on SharePoint “File not found”. Problem “File not found” is one of the more annoying errors one can stumble upon when trying to activate a feature. There are quite a few reasons that can cause this error, but after the obvious ones (some files failing to be included in the package, botched wsp deployment, errorenous urls in event receiver) one thing to check might be the alternate access mappings.…Continue reading “File not found”-error when trying to activate custom feature on SharePoint

SharePoint List Field Name creation dialog - the internal names for created fields are generated from the display name, and often end up being quite messy!

Programmatically creating readable internal names for new SharePoint fields

This post is about a small programmatic workaround to creating new SPFields for SPLists in SharePoint with human-readable internal names. This is mainly a usability improvement for your editors (and doesn’t change your life that much), but at the very least they will probably appreciate it! In short, I’ll show you how to avoid SharePoint’s dirty encoding (like replacing a space with “_x0020_”). This appliesto when you’re using server-side code to generate fields. Problem: non-readable internal names for SharePoint list fields When you create a…Continue reading Programmatically creating readable internal names for new SharePoint fields

SharePoint Authentication prompt

Windows Authentication fails on SharePoint for all hostnames (other than localhost)

This post describes how to fix Windows Authentication on a SharePoint server failing on other local addresses than plain old localhost. Symptoms You get the standard Windows/Basic Authentication prompt when accessing your SharePoint site, but the site won’t accept your credentials when your accessing the site using an address like http://website. However, using address like http://localhost works fine (but of course may cause other problems). You also get event log entries like this (most likely in System -category): The program w3wp.exe, with the assigned process ID,…Continue reading Windows Authentication fails on SharePoint for all hostnames (other than localhost)