简体   繁体   中英

Returning Resized Image from WebImage in RouteHandler

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?

Adding

requestContext.HttpContext.Response.End();

before return null; did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM