Through this blog, it is my effort to share experiences with the community and make the journey enjoyable.

Wednesday, August 20, 2008

Redirecting to custom application page, after uploading documents

Overview -
SharePoint Upload.aspx page is used for uploading documents from the document libraries and other lists. Upload.aspx is called, by passing various Query String parameters like ListId, Source, MultipleUpload etc. MultipleUpload parameter is used to display controls for single or multiple file upload. After uploading the documents, code redirection happens to AllItems.aspx or EditForm.aspx, based on scenarios. Since, redirection happens in code behind, creating custom application page to perform upload function and redirecting, serves the purpose. To start with, approach looks like, lot of development effort. However, it is very simple, since we are reusing the functionality provided in upload.aspx. This enables you to inject specific business rules and processes for adding files to the library. This also enables to write specific business processes as well custom file processing.

Creation of custom aspx page with code behind library. Instead of creating a completely new Upload page, you will derive from the existing Upload page and functionality and modifying the functionality you want. To do this, you reference the Microsoft.SharePoint and Microsoft.SharePoint.ApplicationPages assemblies in your project. Then you create a class that derives from the Microsoft.SharePoint.ApplicationPages.UploadPage class. This class uses the Microsoft.SharePoint and Microsoft.SharePoint.ApplicationPages namespaces. The functionality that we want is redirect the users to custom application page.

C# Code -
namespace UploadRedirect
public class CustomUpload : Microsoft.SharePoint.ApplicationPages.UploadPage
protected override void OnLoad(EventArgs e)
//Set the literal control text to redirect page.
this.ConfirmationURL.Text = { Complete Url to the Redirect Page }


Creating the ASPX Page –
Create new custom aspx page, based on Upload.aspx from Layouts directory. Add the reference of above creating assembly on the top of custom aspx page. Rest of the content remains the same. Deploy the assembly in Global Assembly Cache and custom upload aspx page in layouts directory. Test the page, by passing the same query string parameters as being passed in upload.aspx.

Redirecting the User to the New Upload Page -
Change the links for Upload and Multiple Upload in the Document Library. There can be different approaches for the same. Custom Document Library Template with the path to custom upload page, would be one of them. Using Javascript of overriding the links, can be another.

References -
Microsoft MSDN Article -
Preventing Record Modification but Allowing Metadata Modification by Overriding the Upload Page in Windows SharePoint Services 3.0



  1. I cannot get this to compile - it doesn't seem to recognize UploadPage as a namespace of Microsoft.SharePoint.ApplicationPages.

    Please advise.

  2. I am having trouble getting this to work. I have my reference to Microsoft.Sharepoint but, I keep receiving "UploadPage does not exist in the namespace" on Build?


Search This Blog


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway. All posts are provided "AS IS" with no warranties, and confers no rights. In addition, my thoughts and opinions often change, and as a weblog is intended to provide a semi-permanent point in time snapshot you should not consider out of date posts to reflect my current thoughts and opinions.

Popular Posts

Total Pageviews