views:

589

answers:

1

I tried several ways to URL rewrite. The first way the image mime was clobbered and was consider an octet stream which didnt allow me to view the image in a browser (unless it was using img src). The 2nd way i wasnt convince it worked. Firefox displayed the img but said the length was 0 (i think it only worked bc it was in my cache).

How do i properly rewrite the image /abc/id/title.png to the internal location /static/user/name/id.png

+1  A: 

In ASP.NET I might do something like this:

Response.Clear();
Response.ContentType = profile.AvatarMimeType;
Response.BinaryWrite(profile.Avatar.ToArray());

Where profile.AvatarMimeType is an appropriate mime type for a gif, jpeg, or png.

And where profile.Avatar.ToArray() is a binary content from the db sent out as an array of data!

Andrew Siemer
I have not tried this in ASP.NET MVC but I think that it should still work as the URL simply gets you to the resource that executes this code.
Andrew Siemer