<p>How would one display any add content from a "dynamic" aspx page? Currently I am working on using the System.Web.HttpResponse "Page.Response" to write a file that is stored on a web server to a web request.</p>

<p>This would allow people to hit a url to the type <a href="http://www.foo.com?Image=test.jpg" rel="noreferrer">http://www.foo.com?Image=test.jpg</a> and have the image display in their browser. So as you may know this revolves around the use of Response.ContentType.</p>

<p>By using </p>

<pre><code>Response.ContentType = "application/octet-stream";
</code></pre>

<p>I am able to display images of type gif/jpeg/png (all i have tested so far), bit trying to display .swf or .ico files gives me a nice little error.</p>

<p>using</p>

<pre><code>Response.ContentType = "application/x-shockwave-flash";
</code></pre>

<p>I can get flash files to play, but then the images are messed.</p>

<p>So how do i <strong>easily</strong> choose the contenttype?</p>

This is part of a solution I use on a local intranet. Some of the variables you will have to collect yourself as I pull them from a database but you may pull them from somewhere else.
The only extra but I've got in there is a function called
getMimeType
which connects to the database and pulls back the correct mine type based on file extension. This defaults to application/octet-stream if none is found.
```
```
// Clear the response buffer incase there is anything already in it.
Response.Clear();
Response.Buffer = true;

// Read the original file from disk
FileStream myFileStream = new FileStream(sPath, FileMode.Open);
long FileSize = myFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
myFileStream.Read(Buffer, 0, (int)FileSize);
myFileStream.Close();

// Tell the browse stuff about the file
Response.AddHeader("Content-Length", FileSize.ToString());
Response.AddHeader("Content-Disposition", "inline; filename=" + sFilename.Replace(" ","_"));
Response.ContentType = getMimeType(sExtention, oConnection);

// Send the data to the browser
Response.BinaryWrite(Buffer);
Response.End();
```
```