Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Original Title:

<nativehr>0x81020089</nativehr> in ItemUpdating (i.e. Synchronous) Event Receiver


Edited Question:

In the past when you created an item-based, synchronous event receiver that canceled the event and showed the user a message, you received custom SharePoint error page displaying your message. This is no longer the case and to achieve this behavior, which was the default in the past, you need to modify the Web.config as described below. Other than modifying the Web.config is there any method to display the custom error message to users as was done in the past?


Original Question and Additional Details:

I am receiving the above error in a "yellow screen of death" ASP.NET error page in an ItemUpdating event receiver where I have done the typical:

properties.Status = SPEventReceiverStatus.CancelWithError;
//It does not matter if I use Cancel or CancelWithError
properties.ErrorMessage = "You must be a member of the " + MarketNeedGroups.EngineeringManagers + " group to modify the " + field + " field";
properties.Cancel = true;

Some people seemed to think that it was due to the CustomErrors being set to "off" but that was clearly not the issue I was having as that was set to RemoteOnly on my dev box.

Another person suggested changing

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">

to CallStack="false" which I did and it corrected the issue. The amount of crazy answers I saw from people who clearly had no idea what was going on, however, lead me to question this as the best choice. Are there any other possibilities to correct this?

Edit:

I went back and checked some old code that has been in production for the better part of a year now. In said code I perform the same cancel but in an ItemDeleting Event Receiver. If you see this article on MSDN you will notice that it should present the user with a much less scary custom SharePoint error message. In the past my ItemDeleting event receiver displayed the same style of custom error message. It no longer does this. It now presents the user with a the YSOD. I verified the settings of the Web.config from a backup dated from over a year ago and CallStack="true" was exactly the same.

I don't want to modify this setting if I don't have to, but since the chances of me figuring out what has changed are zero, I will just keep this setting in the Web.config set to false. I certainly do not want my users to see the YSOD page as this will generate helpdesk tickets because users will not actually read the message, they will just assume that there was some sort of error in code. There is even discussion of this issue in the MSDN article above in the comments section.

In the Asynch events the error page still seems to be displayed properly. Meaning this exact code does not generate a YSOD but displays the custom SharePoint error.

share|improve this question
    
What's the question? If you won't want the YSOD, haven't you solved that? Or are you asking the best way to cancel the event? Or are you asking why the two settings? –  Andy Burns Oct 4 '12 at 16:19
    
Are there any other possibilities (than modifying the WebConfig as shown) to correct this? –  Robert Kaucher Oct 4 '12 at 16:49
    
Are you asking "Are there other way apart from changing the Web.Config to change the error page shown in SharePoint?" I'm struggling to see what you're trying to 'correct' - SharePoint is behaving as I'd expect an ASP.NET application to behave. –  Andy Burns Oct 5 '12 at 10:14
    
@AndyBurns You might think this is normal behavior, but it wasn't what occurred in the past. Please see my edit. –  Robert Kaucher Oct 5 '12 at 14:32

2 Answers 2

up vote 0 down vote accepted
+50

I am afraid, modifying the web.config is the only way here.

Also, apart from changing the CallStack = "false", you should also set the <customErrors mode="On" />. Here is the relevant part of your web.config showing the changes:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <configuration>
        ...
        <SharePoint>
            <SafeMode MaxControls="200"
                CallStack="false"
                DirectFileDependencies="10"
                TotalFileDependencies="50"
                AllowPageLevelTrace="false">
                ...
            </SafeMode>
        ...
        </SharePoint>
        <system.web>
            ...
            <customErrors mode="On" />
            ...
        </system.web>
        ...
    </configuration>
share|improve this answer
    
Pretty much what I figured. Any idea what caused the change in behavior? –  Robert Kaucher Oct 9 '12 at 13:24
    
Hmmm here is a way to change the web.config programmatically. somebody might have done that maybe? stackoverflow.com/questions/3512974/… –  Vardhaman Deshpande Oct 9 '12 at 16:09
    
No, that would not have occurred. This also seems like a more wide spread issue than just my environment if you see the MSDN article I link to in the question. –  Robert Kaucher Oct 9 '12 at 19:49
    
Just an FYI, it doesn't seem that the CustomErrors setting actually matters so long as the CallStack attribute is set to false. At least not as far as the scope of my question is concerned. –  Robert Kaucher Oct 10 '12 at 12:29

The SPEventReceiverStatus enumeration now has a CancelWithRedirectUrl. If I understand correctly you want to show an errormessage to the user that informs why the action was cancelled. For an example see: http://msdn.microsoft.com/en-us/sp2010devtrainingcourse_listsandschemalab_topic4.aspx.

I hope this helps.

share|improve this answer

Your Answer

 
discard

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.