Is it the static way for displaying images? Can i dynamically display
.jpg
files in this way? For example, I convert images into .jpg format and
display
them on the web page in runtime on request.
David
You want to create an aspx to handle displaying an image, have it do the
WriteFile() using a QueryString argument passed in.
Let's call this page foo.aspx and the querystring arg is imageUrl. Then
in my main page (where I want to show the image) I would do
<img src="foo.aspx?imageUrl=images%2Fimage002.jpg" >...
<img src="foo.aspx?imageUrl=iamges%2Fimage003.jpg" >...
note I URL encoded the / to %2F. Now in foo.aspx, you want to remove all
code, whitespace, html, everything from the .aspx file; then in the
..aspx.vb or .aspx.cs do all the work of displaying the image via
WriteFile() (write the file with url = imageUrl). You can also Google
around a little bit for a thorough example, you'll want to set the
content-type to the image type you are using in foo.aspx as well as some
miscellaneous response settings.
Why remove everything from .aspx? You can only have 1 MIME type per
response. Previously (as pointed out the other poster) you had
intermingled image and html data. Doesn't work. And if anything is in
your .aspx (other than directives), it will be compiled as a Literal
(HTML) and spit out with the response, once again mixing MIME types
inadvertently.