I\'d like to create a dynamic thumbnail resizer so that you can use the following URL to get a resized image:
http://server/images/image.jpg?width=320&height
You could also consider:
Both would allow you to remove the need to write as a controller, I think this is cleaner.
Very basic example of your own route handler (from memory)...
Register as a normal route:
/* Register in routing */
routes.Add("MyImageHandler",
new Route("my-custom-url/{folder}/{filename}",
new ImageRouteHandler())
);
/* Your route handler */
public class ImageRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
string filename = requestContext.RouteData.Values["filename"] as string;
string folder = requestContext.RouteData.Values["folder"] as string;
string width = requestContext.HttpContext.Request.Params["w"] as string;
string height = requestContext.HttpContext.Request.Params["h"] as string;
// Look up the file and handle and return, etc...
}
}
Hope these help. Lots of ways to extend and achieve :)