Q:

Route all requests for files to a simple folder name for serving PDFs

I would like to make a small URL for all files in a folder.  So instead of writing:
http://mywebsite.com/content/pdf/samples/Myfile.pdf

I can write:
http://MyWebsite.com/samples/myfile.pdf

I have added 
routes.MapPageRoute("Sample", "Sample/{*fullpath}", "~/Content/pdf/samples/{*fullpath}", False)

which does seem to redirect, but I get There is no build provider registered for the extension '.pdf'. However, it works fine when I put an ASPX file in the folder and navigate to it.  So then, I add: 
<add extension=".pdf" type="System.Web.Compilation.PageBuildProvider" />

Which now gives me a parser error because the page is filled with gibberish.
Same thing happens for images.
Is what I am asking not doable?  It seems that there should be a way to have it understand to serve or download the page as it would without the routing.
Is there a better way?

A:

Well, I found something that works, though I don't know how efficient or great it is.
I kept
routes.MapPageRoute("Sample", "Sample/{*fullpath}", "~/Content/pdf/samples/{*fullpath}", False)

Then I added the following to the Web.Config.
<system.webServer>

    <rewrite>
      <rules>           
        <rule name="Redirect PDFs" stopProcessing="true">
          <match url="^sample/?(.*)$" />
          <action type="Redirect" url="/Content/SampleReports/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>

</system.webServer>

I would still love to know if there is a better, faster, or easier way to do this.  Also, this works for PDF files.  I assume I would need to make a rule for each type of static file I want to serve from the sample directory.

