Go Back   SitePoint Forums > Forum Index > Program Your Site > .NET
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jun 22, 2009, 01:37   #1
NightStalker-DNS
SitePoint Wizard
 
NightStalker-DNS's Avatar
 
Join Date: Jul 2004
Location: Cape Town, South Africa
Posts: 1,587
Dynamic Images with MVC

Hey guys

I have finally started dabbling in MVC. Not to bad so far. Its pretty cool actually, even tho it "seems" to be a bit of a step backwards as its got not databinding, etc. lol.

But anywayz, to my issue at hand. My site in asp.net usually have a thumbnailer.ashx file that does all the dynamic resizing for my needs. It is used like this:

src='thumbnail.ashx?section=1&w=640&h=&contrain=0&image=file.jpg'

My question is how do handle this in MVC?

I tried this:

public FileStreamResult Get(int? w, int? h, int? constrain, string image)

which then gets an image from a file, does its calculations and resizing then outputs it like this:

MemoryStream fs = new MemoryStream();

oThumbnail.Save(fs, jpegICI, encoderParams);
return new FileStreamResult(fs, "image/jpeg");

But all that does is output a string:

http://devserver/Thumb/Get/240/0/0/opel_ruhestaette.jpg.

And if I view the source its:
<img src="
http://devserver/Thumb/Get/240/0/0/opel_ruhestaette.jpg" border="0" />

So any ideas or help with this would be much appreciated. I have tried googling this, but found nothing yet.

Thanks
NightStalker-DNS is offline   Reply With Quote
Old Jun 22, 2009, 04:15   #2
NightStalker-DNS
SitePoint Wizard
 
NightStalker-DNS's Avatar
 
Join Date: Jul 2004
Location: Cape Town, South Africa
Posts: 1,587
Ok, I got it working thanks to this link: http://blogs.msdn.com/miah/archive/2...er-action.aspx

Didnt work out the box, but slight tweak got it to wat I can use. Is this a good way to do it? Or are there better ways of doing this in MVC?
NightStalker-DNS is offline   Reply With Quote
Old Jun 23, 2009, 07:00   #3
dhtmlgod
ALT.NET - because we need it
SitePoint Award Recipient
 
dhtmlgod's Avatar
 
Join Date: Jul 2001
Location: Scotland
Posts: 5,124
Looks ok, but there is s File() method that you can use to the same thing in the Controller.
dhtmlgod is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 18:07.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved