SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Long story short, we have a document library that has two fields that we use to identify files. Our file names are built through SPList objects as well as what a user provides. Since users can choose the same filename (and would be differentiated by our column "metadata") we rename them with GUIDs when we store them into the library.

When users want to retrieve the files however, we are having HUGE issues renaming the files back to the user (using the SharePoint column values and not using the GUID as the filename). We've taken the OOB Download.aspx page but found that it isn't as easy as:

this.Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + SPHttpUtility.UrlEncodeFilenameForHttpHeader("My new File Name.docx") + "\"");

We run into issues stating that the file's contents are corrupted which is strange considering we're only renaming the Filename in the header. Can anyone shine some light onto this issue?

Edit: I'm in a rush at the end of the day here, please let me know if you want more code samples. We aren't overwriting SharePoint's Download.aspx file, we just used a reflector to grab the code and make our own page.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.