O'Reilly logo

ASP.NET MVC 2 Cookbook by Richard Kimber, Andrew Siemer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying the size of an ImageResult

In this recipe, we will create another custom ActionResult. This one will also render an image, but in this case we will allow the user to set the size of the image.

Getting ready

Nothing is required to get this recipe running other than writing some quick code. Due to the changes of how this recipe works, we won't actually be building off of the last recipe.

How to do it...

  1. Let's start by creating a new ASP.NET MVC project.
  2. In the models folder, we create a new class and name it ImageResizeResult. Then, we set this new class to inherit from ActionResult.

    ImageResizeResult.cs:

    public class ImageResizeResult : ActionResult
    {
    
  3. At the top of the class we are going to specify four private variables for use in our class. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required