html - CSS image pathing when sourced from a different host using IE -
html - CSS image pathing when sourced from a different host using IE -
[setup: asp.net mvc 3 on azure azure blob storage css files , assets on https]
i'm creating website selects appropriate css style sheet depending on host beingness selected - allows website enabled different branding altered css, controlled referring host. mechanism uses mvc controller detects host, redirects (using asp.net rewrite rule) reference css file , associated assets (i.e. images) separate location. example:
requests www.host1.com reference css file mycssandassets.mycoreserver.com/css/www.host1.com
requests www.host2.com reference css file mycssandassets.mycoreserver.com/css/www.host2.com
this works apart 1 minor issue, things break when using net explorer. in short, net explorer obtains css file, cannot reference images referenced in file. here, images referenced using relative path actual css file, assumption beingness (from w3c)...
partial urls (as defined in [rfc1808]) interpreted relative base of operations url of style sheet, not relative base of operations url of source document.
an illustration of pathing used (where file in same directory css file has been redirected to)...
background-image: url('icon-big-buttons.png');
in chrome , firefox, things behave expected image retreived same location css file. next screenshot of fiddler - first 4 entries ie, lastly 3 chrome - these requests made same site.
note: clarification, 'css' controller mvc site redirects css file in azure blob storage.
here ie assuming images hosted on source host whereas chrome correctly references images location of css file.
this feels much ie client-side issue searches (while hardly exhaustive) have not been fruitful. know utilize absolute pathing want avoid there big number of css files maintain...
any help or thoughts appreciated.
so after lunchtime pizza took fresh @ problem per bartdude's advice - time looking @ rewrite rules , appears these causing problem after running sanitised test.
in short, used rewrite rule redirect core site on css , assets. browsers ie worked fine. without performing redirect, straight referencing css , assets - ie played nice.
my solution utilise sec rewrite rule, 1 redirect css , path actual assets. rule bypass controller , navigate appropriate host.
<rules> <!-- first rule used redirect controller style sheet --> <rule name="csstoazure" stopprocessing="true"> <match url="css-source/(.*)" /> <action type="redirect" url="https://mycssandassets.blob.core.windows.net/css/{r:1}" /> </rule> <!-- sec rule capture images referenced in style sheet using host name --> <rule name="cssieplayingnice" stopprocessing="true"> <match url="css\/(.*\.png|.*\.gif|.*\.jpg|.*\.eot|.*\.htc)" /> <action type="redirect" url="https://mycssandassets.blob.core.windows.net/css/{http_host}/{r:1}" /> </rule> </rules>
hope may help others...
html css asp.net-mvc internet-explorer azure
Comments
Post a Comment