views:

179

answers:

2

i am using URL rewriting in my asp.net application using regx

virtual URL is

/ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx

original URL is

/ProductDatabaseCMS/Product.aspx?PROD_ID=${product}

application path is ~/ProductDatabaseCMS

my application has master page that uses style sheet and the path is

~/App_Themes/Styles/Style_Sheet.css

i am requesting the URL

/ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx

from one of the webpage of application using Hyperlink control but in that case stylesheet is not working for this page Because it is taking path

~/ProductDatabaseCMS/(?<category>\w*)/Product/App_Themes/Styles/Style_Sheet.css

what i have to do in this case.

A: 

If you use a relative URI to reference the external stylesheet, you have to consider this: Relative URIs are always resolved from a base URI which is the URI of the current resource if not declared otherwise.

So if you request /foo/bar and there is a relative URI reference css/baz.css in the HTML document, it would be resolved to /foo/css/baz.css as /foo/bar is the base URI.

To solve this problem you have two options:

  1. use absolute URIs or at least absolute paths to reference the resources (e.g. /App_Themes/Styles/Style_Sheet.css), or
  2. set a suitable base URI using the BASE HTML element (e.g. <base href="/">) so that every relative URI is resolved from that new base URI.
Gumbo
A: 

Use a "root-relative path" for the CSS href. You start the href with "/", that's all.

Try: /App_Themes/Styles/Style_Sheet.css

annakata