PathInfo And ASP.NET Themes: Why Can’t They Work Together?

If you ever worked with ASP.NET Themes and Skins, you know that stylesheet links are added to the head section of the HTML document.

The rendered URL to these stylesheets is always relative to location of the page being requested.

So, for a request to:

http://MySite/Section/Default.aspx

you’ll get:

<link href="../App_Themes/Default/Styles.css" type="text/css" rel="stylesheet" />

which will make the web browser request for:

http://MySite/App_Themes/Default/Styles.css

and it all works fine.

Well, it works fine until you need to navigate to:

http://MySite/Section/Default.aspx/PathInfo

You’ll get the same stylesheet reference and the browser will request for:

http://MySite/Section/Default.aspx/App_Themes/Default/Styles.css

This happens because the web browser has no knowledge of what PathInfos are. It only accounts for the number of forward slashes (/).

I’ve filed a bug on Microsoft Connect about this.

4 thoughts on “PathInfo And ASP.NET Themes: Why Can’t They Work Together?”

  1. That’s strange, I’ve used it all the time and never had problems.
    The issue arises when you have webapplication inside webaplications i guess,
    I’ve just build one webapplication with + 50 pages with alot of sub dirs and it works.

    /
    /Customer
    /Apps
    /Apps/PrivateToolkit
    /Apps/PrivateToolkit/CommercialAction
    /Apps/PrivateToolkit/WorkQueues

  2. Hi,
    Instead of using which is relative to the page it is used on.
    try using which is relative to the root of the web application – this should solve any problems with using pathinfo.

Comments are closed.