FlexCelHtmlImageHandler Class
This is a base image handler you can use to create your own. This code is adapted from here: http://www.hanselman.com/blog/PermaLink,guid,5c59d662-b250-4eb2-96e4-f274295bd52e.aspx We would like to thank Scott Hanselman for the insightful article.
Remarks
To use this handler, include the following lines in a Web.config file. <configuration> <system.web> <httpHandlers> <add verb="*" path="flexcelviewer.ashx" type="FlexCel.AspNet.FlexCelHtmlImageHandler,FlexCel.AspNet"/> </httpHandlers> </system.web> </configuration> You might need to change the name "flexcelviewer.ashx" if you change FlexCelAspViewer.ImageHandlerName. Both names need to be the same.
Syntax
Namespace: FlexCel.AspNet
public class FlexCelHtmlImageHandler: IHttpHandler
Methods
Name | Description |
---|---|
ProcessRequest | This method will validate the parameters, and then call GetImage to get the real data. When inheriting from this class, you normally only have to override ValidateParameters GetImage |
ValidateParameters | Override this method to check the parameters are valid. |
ImageExists | Override this method to provide a 404 error if the image has been deleted or doesn't exists. |
GetImage | Override this method to return the image. WARNING: Whatever you do here, make really sure you return only the indented image. A NAIVE IMPLEMENTATION OF THIS METHOD MIGHT RESULT IN A HUGE SECURITY HOLE. An attacker could use an implementation that just returns a file to retrieve any file in the server. |
Properties
Name | Description |
---|---|
IsReusable | This instance can be reused. |
RequiresAuthentication | Override this property in a descendant class if you do not want to ask for authentication for this image handler. |