Search code examples
c#asp.neturlrewriter

How is an image served from a URL with an ASPX extension?


Can Somebody tell how to create such kind of urls

for example if you see the url

http://office.microsoft.com/global/images/default.aspx?assetid=ZA103873861033

you will redirect to an image ..

my question is , though this url is an image..its extension is aspx..how is it possible. how to create such kind of url's

Thanks


Solution

  • This is a common method for displaying an image that's stored as a binary object in a database. One tutorial, among many, can be found here.

    Essentially, what they're doing is using the aspx page to accept the URL parameter which tells them what image to fetch from the database. Then in the response they clear all output and headers, set the headers for the image, write the binary data to the response stream, and close the response stream.

    So it's not really "redirecting" you to an image. The "page" being requested turns out to be an image resource in the response.