locked
Can you assign a filename to an image processed by a Handler? RRS feed

  • Question

  • User-1352496656 posted


    When I retrieve an image from a database using a Handler, if I try to save the file the filename is simply the name of the Handler.  Since I am also pulling down the name of the image, is there a way to set the image name to that when someone tries to "Save As..."?

     

    Thanks...


     

    Friday, September 18, 2009 4:16 PM

Answers

  • User-520527587 posted

    You can use URL rewriting http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

    What you can do is make it so that all requests to this

    www.mysite.com/imagehandler/anyimagename.jpg

    redirects to this

    www.mysite.com/imagehandler.ashx?image=anyimage.jpg

    Then when you get it from the database and show it the address used to access it will be the name of the file.

    Note: you will need to map the jpg extension or a wildcard to asp.net.

    I hope that helps,

    Brendan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 19, 2009 12:25 PM