I implemented an event receiver and attached it to a MOSS 2007 document library. I overrode the synchronous itemUpdating method and perform some validation before letting the update operation proceed. In case validation fails, I use the following code to cancel the update and indicate an error to the user:

public override void ItemUpdating(SPItemEventProperties properties)
    // Perform some validation...
    if (/*validation fails*/)
        properties.Status = SPEventReceiverStatus.CancelWithError; // line 1
        properties.Cancel = true;                                  // line 2
        properties.ErrorMessage = "Validation error";              // line 3

I expected to see the SharePoint error page with a display of the error message. Instead, I see the rather unamiable IIS server error page with the full stack trace.

I switched around lines 2 and 3, and I even replaced SPEventReceiverStatus.CancelWithError with SPEventReceiverStatus.CancelNoError, to no avail. Any ideas???

1 Answer 1


The "yellow" ASP.NET error page is probably due your "dev" web.config configuration that shows up raw errors (see How to set customErrors attribute in sharepoint 2013?).

However, ErrorMessage will always end-up with an error message to the end-user, just less ugly than the yellow one. No way to display a nice warning box :(

  • Thanks... it was my dev environment web.config. I followed that article and updated the settings to not display custom/full errors.
    – Web User
    Commented Dec 16, 2015 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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