Rank: Newbie
Joined: 7/4/2008 Posts: 6 Location: Copenhagen, Denmark
|
Hi, I'm converting a aspx website into umbraco but I've got an image-conversion problem. In my old aspx pages I refer to images stored in my database by applying the following imageurl to an image:
image.ImageUrl = "~/loadpicture.aspx?id=" + myId;
and then the code inside the loadpicture.aspx codebehind goes:
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["id"]; // fetch the image from the db if (id != null) { ImageTableAdapter imageTA = new ImageTableAdapter(); Image.ImageRow imageInfo = imageTA.GetImageById(Convert.ToInt16(id))[0]; Response.BinaryWrite(imageInfo.image); } }
This works within the aspx pages. Within umbraco I've converted the loadpictures.aspx to a user control and then created a macro and a template using this macro. The template goes: <?ASPNET_FORM> <?UMBRACO_MACRO macroAlias="loadPicture" myProperty="[@id]"></?UMBRACO_MACRO> </?ASPNET_FORM>
using the "myProperty" I get the query string across... However, when I do: http://localhost/loadpicture.aspx?id=myId
I dont get the picture showing as I do with the aspx pages but instead I get the "data" e.g
�PNG ��� IHDR�������]���o��9���sRGB�������gAMA�����a��� etc...
So finally to my question: What do I need to add to my template in order to get umbraco to convert the data to a real image?
Br, Johannes
|
 Rank: Addict
Joined: 7/19/2006 Posts: 649 Location: Preston, UK
|
dolberdinho,
Make sure in your template that writes out the page you dont have any other html content / macros etc other than your image write one. Also you need to set the content / type header by default it will be text/html it needs to be set to image/jpeg so in your page_load before
Response.BinaryWrite(imageInfo.image);
do
Page.Response.ContentType = "image/jpeg";
Regards
Ismail
Level 2 certified. If it aint broke dont fix.
|
Rank: Newbie
Joined: 7/4/2008 Posts: 6 Location: Copenhagen, Denmark
|
Thanks a lot!! It works!
|