I’m using the iis7 URL Rewrite module and it’s working fine, except for two things. Being new to this, I might be missing something obvious.
1) My URL gets converted from
www.mysite.com/search.aspx?fName=John&sName=Smith
to www.mysite.com/John/Smith. This works fine, but if I add a trailing / , a few images on the site disappear, wheras a few don’t. (They’re all in the same location). However, the search results are fine.
2) Is it possible to make cerain querystrings optional? Server side, this is implemented (i.e. if nothing is entered, then assume a default value). But how would this work with the URL rewrite module?
e.g. www.mysite.com/John would search for John and use a default value for the sName parameter.
Thanks for any help.
I can’t help with the optional query string parameters I’m afraid, but the images one should be fairly easy:
How are you declaring the image paths in your markup? If you are using relative paths (i.e.
src="../Images/someimage.png"then adding a trailing slash to the URL is telling the browser that the /Images/ folder is under the folder /John/ instead of being at the root of the site.If you are using HTML
<img />tags, you should prefer a virtual path:src="/Images/someimage.png"– this tells the browser to request the image path from the root of your site.If your application isn’t running in the root of the site, you can also use the ResolveUrl method that is part of the page and control object tree, this allows you to pass in a virtual path of the form
~/Images/someimage.pngand the framework will work out what the correct path should be.