views:

335

answers:

1

Hi,

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.

+1  A: 

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.png and the framework will work out what the correct path should be.

Zhaph - Ben Duguid
Can't believe I missed that. I was looking at the wrong master page, which has the same buttons, just different positions. D'uh! Thanks, the image problem is fixed.
keyboardP
I managed to do the rewrite for part 2 by adding another rule and used a URL without the optional parameters as the template. Then, on the server, I simply checked each parameter and if it was missing, I assigned it a default value.
keyboardP