ItemAdding Event Receiver - properties.RedirectUrl not working in multiple file upload


  • Hi,

    I have an ItemAdding event receiver attached to an OOB document library that redirects to an error page if the file being uploaded has a non-permissible file extension. The list of permissible file extensions is specific to this library and is not the same as the blocked file types defined in Sharepoint Central Administration.
    The problem is the redirection to the error page doesn't happen when I am uploading multiple files (from the file upload page when STSUpld.UploadCtl is used), even though the event receiver is triggered. However, in case of uploading single file (from the file upload page where the basic file upload control is used) the page gets redirected to the error page. Here is the event receiver code:

            public override void ItemAdding(SPItemEventProperties properties)

                    properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
                properties.RedirectUrl = "/_layouts/FileCollaboration/FileCollaborationLandingPage.aspx";

    Can anyone please suggest how to solve the redirection problem in case of multiple file upload?
    • Edited by Farhan82 Sunday, December 30, 2012 9:00 AM
    Saturday, December 29, 2012 6:20 AM


All replies

  • Hi Multiple file uploads make use of a ActiveX control. The parameters to this activex control need to be overridden in order to  redirect the user to a specific page. Unfortunately this cannot be achieved using an event handler. The only way to do this is specified in Here you will have to create your own custom page for uploading multiple documents.
    • Proposed as answer by Balaji Sa-MSFT Sunday, December 30, 2012 8:54 PM
    • Unproposed as answer by Farhan82 Tuesday, January 01, 2013 2:33 PM
    Sunday, December 30, 2012 8:54 PM
  • Thanks for the response Balaji. While the solution suggested in the blog post deals with the case where redirection to another (custom) page is required "after" file upload but is not for the case where rerouting is to happen "before" the file gets uploaded to the document library. That's why I chose ItemAdding event receiver. Since event receiver as you said cannot achieve this so is there any other approach to solve my problem?


    Tuesday, January 01, 2013 2:42 PM
  • farahan can you try this
    Wednesday, January 02, 2013 7:11 AM
  • Hi Farhan,

    The only approach is to create your own custom upload page, and write the code yourself. You cannot make use of the OOTB upload control in that case as far as I know.


    Wednesday, January 02, 2013 1:26 PM