Redirect to URL in SharePoint Foundation 2010

Applies to: SharePoint Foundation 2010

Microsoft SharePoint Foundation 2010 now allows event receivers to provide a redirection URL to provide custom messages through the user interface (UI).

Redirect URL

Microsoft SharePoint Foundation 2010 now supports an event receiver that provides a redirect URL to an error message. This capability allows you to customize your error messages and provide specific guidance for users, allowing for different user experiences, depending on the error. However, these redirect URLs do not work in all cases. For example, when users save files from a Microsoft Office application, the redirect URL is ignored.

The redirect URL feature works with all pre-event receiver types (such as SPWebEventReceiver, SPListEventReceiver, and SPItemEventReceiver) in cases where the action is being cancelled. To support the new user interfaces, SharePoint Foundation 2010 added the CancelWithRedirectUrl field to values in the SPEventReceiverStatus enumeration.

SPEventReceiverStatus
{
    CancelNoError,
    CancelWithError,
    CancelWithRedirectUrl,
    Continue
}

CancelWithRedirectUrl allows you to specify a redirect URL for a Web browser UI. Use the URL that is specified by the RedirectUrl property of the SPEventPropertiesBase object to navigate to alternate pages. This URL should be a server-relative URL, and cannot contain ECMAScript (JavaScript, JScript).