For example I have site http://localhost/site
In IIS I set that 404 error causes redirection to default.aspx
If I type something like http://localhost/site/nodirectory , (there are no such folder) all works perfectly.
But if I only add slah at end http://localhost/site/nodirectory/, page can’t display css and images.
Images and css are located in their own folder. I tried different paths: “gfx/logo.gif”, “/gfx/logo.gif”
Does anyone have some ideas about that?
If your css and images are relative paths, say
ResolveClientUrl("~/gfx/logo.gif")this renders to the client assrc="gfx/logo.gif", which the browser with a slash thinks is/nodirectory/gfx/logo.gifinstead of just/gfx/logo.gif.To resolve this, don’t use
.ResolveClientUrl(), use.ResolveUrl(), this will make the src rendersrc="/gfx/logo.gif"The beginning/makes it definitive, it’s that path from the root of the domain.You’ll see this same hebavior if you’re doing paths that start with
../orgfx/yourself…make them relative to the application base so there’s no chance of confusion.