views:

556

answers:

3

I tried using the IHttpModule and managed to convert the urls just fine, but all of my images returned path error (all going through the new url directory).

whats the solution?

A: 

You can try using a URL rewriter such as IIRF.

With IIRF you can use regular expressions to parse the incoming URL as you wish, then send it to the right place.

They have examples built in on how to do all that in the IIRF download.

CubanX
+1  A: 

You need to make sure that you use the "~/" path notation on your images and make sure that they are all server controls with runat='server'. Otherwise the images urls won't get rewritten.

For example if you have a page that gets rewritten from:

/Item/Bicycle.aspx

to

/Item.aspx?id=1234

Then what will happen is that an image reference like this:

<img src='images/something.gif' />

will break. So instead you have to do something like this:

<asp:image imageurl='~/images/something.gif' runat='server' id='img1'/>

Alternatively you can use absolute paths for your images. Or you can push as much as possible into your .css files.

Keltex
A: 

What's the solution? Use the new routing engine in .NET 3.5 that started in the MVC project and got elevated to stand-alone status. :)

If Keltex's suggestion doesn't solve your specific problem look at ResolveUrl and ResolveClientUrl.

sliderhouserules