SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using an ItemAdded event handler for doing some validation. If my validation fail is it possible to redirect the user to another page. Ideally it would be good to show the page in a dialog box.

Sadly setting the status on on the SPItemEventProperties to SPEventReceiverStatus.CancelWithRedirectUrl and setting the RedirectUrl does not work.

This is happening on a Document library. This means I can't do the validation in the ItemAdding event as BeforeProperties, AfterProperties & properties.ListItem does not contain the information. (

Update When trying out @Andy code below I get the following:

System.Web.HttpException was unhandled by user code 
Cannot redirect after HTTP headers have been sent
share|improve this question

This works, but only if the form is open in Dialog mode, for some reason.

System.Web.HttpContext _context = null;
public MyEventHandler()
    _context = System.Web.HttpContext.Current;

public override void ItemAdded(SPItemEventProperties properties)
    SPList list = properties.List;
    if (!list.NavigateForFormsPages)
        if (_context != null)
            _context.Response.Redirect(webUrl + "/someurl", false);
share|improve this answer
Sadly getting a "System.Web.HttpException was unhandled by user code" "Cannot redirect after HTTP headers have been sent" – John Jul 16 '12 at 10:56

from my understanding about event receivers is that you cannot edit the users current session as it is back end work.

perhaps a workflow with a workflow history could be used in your case.

if the validation fails you can log the desired redirection URL in the history they can follow it and rerun the workflow when they have made the validation changes

share|improve this answer

If you want to add validation and have the possibility of canceling the update and redirect the user, then you should implement the ItemAdding event receiver instead of the ItemAdded.

share|improve this answer
Your right. There will be a follow up question to this. – John Jul 16 '12 at 12:42… follow up – John Jul 16 '12 at 12:45
As this is a document library the BeforeProperties, AfterProperties & properties.ListItem are all null on ItemAdding so can't. – John Jul 17 '12 at 8:11
Then you should write that in the Question, as the answer will then be that you can't do what you want – Per Jakobsen Jul 17 '12 at 8:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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