0

I'm trying to prevent some records from being deleted from a list. I've got the ItemDeleting event firing and everything works great. I can prevent the item from being deleted just fine. The problem I'm running into is that when I'm logged in as a member of the site [Site Members], I get an Error: Access Denied error message instead of the custom page.

I use the following in my code:

  properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
  properties.RedirectUrl = "/_layouts/folder/CustomError.aspx";

When I'm logged in as an owner of the site [Site Owners], the redirect works just fine.

What kind of permissions issue am I running into that would prevent members, and possibly visitors, from seeing these custom error messages? I should add that I'm doing all this in Visual Studio 2012 and using SharePoint 2010. The custom error page is an Application Page created in VS 2012.

Thank you.

  • Ok. I figured it out. The root of my web application didn't have the user. I added authenicated users to the visitors group and now I can see the error page. Is this standard practice? I see that the application page is added to the layouts folder so access to the web application makes sense. Is there anyway around this? Thanks for any advice. – DrZ Aug 7 '13 at 17:24
1

properties.RedirectUrl = "/_layouts/folder/CustomError.aspx"; will redirect you to the root; properties.RedirectUrl = "~site/_layouts/folder/CustomError.aspx"; will work to direct them to the layouts folder for the site they are currently viewing.

  • Wow! That worked (I had to replace the ~site with the actual value). Thank you so much! – DrZ Aug 7 '13 at 18:00
  • ~site is a token that gets parsed in many places in SharePoint to the URL of the current site; it's possible it doesn't get parsed in that context, in which case you can grab the URL of the site from the event properties rather than hard coding. – lgaud Aug 7 '13 at 18:04
  • properties.RedirectUrl = SPUrlUtility.CombineUrl(properties.WebUrl, "/_layouts/CustomPage.aspx); – mtoregan May 18 '15 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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