YetaWF.Core.ImageHttpHandler Package Documentation

Display
Print

YetaWF.Core.ImageHttpHandler

The YetaWF.Core.ImageHttpHandler assembly/package processes HTTP requests to serve images stored in YetaWF's data files and databases. The HTTP handler is used in the IIS pipeline with ASP.NET 4 and as middleware with ASP.NET Core.

The ImageHttpHandler HTTP handler only serves images stored in data files and databases. It is not used to serve static images, which are referenced directly by URL.

URLs /FileHndlr.image are processed and have the following format:

/FileHndlr.image?Type=imageType&Location=location&Name=name&Percent=percent
/FileHndlr.image?Type=imageType&Location=location&Name=name&Width=imageWidth&Height=imageHeight&Stretch=stretch&Percent=percent
ArgumentDescription
TypeDefines the image type which must match a registered image handler. The YetaWF.Core.Image.ImageSupport.AddHandler method is used to register an image handler.
LocationThis is typically used to define the location of the image. This argument is processed by the registered image handler and is image handler specific.
NameThis is typically used to define the name of the image. This argument is processed by the registered image handler and is image handler specific.
WidthOptional. Defines the width of the rendered image. This can be used to resize the image server-side. If not specified the natural image size is used.
HeightOptional. Defines the height of the rendered image. This can be used to resize the image server-side. If not specified the natural image size is used.
PercentOptional. Defines the size of the rendered image in percent. This can be used to resize the image server-side. If not specified the natural image size is used. Example: 200% doubles the size of the image, 50% shrinks the image size by 50%.
StretchThe default is False. If set to 0 or False, the image will be resized proportionally. If set to 1 or True the image is sized given the specified height/width which may result in non-proportional resizing, changing the aspect ratio.

If an image doesn't exist and cannot be retrieved by the registered image handler, a default image is shown.

Only file types defined in mimeSettings.json with the ImageType: true attribute can be served by the HTTP image handler.

The HTTP image handler adds ETag and Last-Modified headers for caching support and honors the If-None-Match header of incoming requests. The HTTP handler honors the settings Application.P.StaticFiles.Duration (AppSettings.json) which determines caching duration.

The HTTP image handler is implemented by the YetaWF.Core.HttpHandler.ImageHttpHandler class.

Image Handler

An application can add any number of image types which are used by the /FileHndlr.image Type=imageType argument. The YetaWF.Core.Image.ImageSupport.AddHandler method is used to register an image handler. By implementing the desired access methods, the ImageHttpHandler HTTP handler will retrieve the image.

See Also YetaWF.Core