Question

I am developing an application that will have friendly urls to dealer logo images and I would like to use the SqlReader Plugin for ImageResizer.

In the examples I read on their website, you can easily host files from SQL all using the same paths (e.g. ~/databaseimages/{id}) but I'd really like to be able to do something to the effect of ~/michigan/dealers/{id}/logo.jpg where michigan could potentially be any state name.

Is it possible to have a multi-part id (state & id) and have the filename be static as I've shown, or is there a better way to do this?! I really would prefer not to have to change the url if I don't have to.

Solution Based on the accepted answer, this is the URL Rewrite solution I used

    <rewrite>
      <rules>
        <rule name="Rewrite to dealerlogos SqlReader" stopProcessing="true">
          <match url="^([_0-9a-z-]+)/dealers/([_0-9a-z-]+)/logo.jpg" />
          <action type="Rewrite" url="dealerlogos/{R:2}?regionSlug={R:1}" appendQueryString="true" redirectType="Found" />
        </rule>
      </rules>
    </rewrite>
Was it helpful?

Solution

You can do this with URL rewriting of any kind.

ImageResizer provides a built-in event ImageResizer.Configuration.Config.Current.Pipeline.Rewrite that you can attach a handler to if you want to rewrite the path only for ImageResizer requests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top