Returning Resized Image from WebImage in RouteHandler

133 views Asked by At

I am routing my image and resizing them thru an imageRouteHandler. Here is the code.

 public class ImageRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var filePath="(from Request Context)"
            var image = new WebImage(filePath);
            image = image.Resize(width, height);
            image.Write();
            return null;
        }
    }

I am getting this error,

The route handler '...ImageRouteHandler' did not return an IHttpHandler from its GetHttpHandler() method.

the WebImage.Write() will write to the response as i know. What else is needed here?

1

There are 1 answers

0
Ruchan On BEST ANSWER

Adding

requestContext.HttpContext.Response.End();

before return null; did the trick.