Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Can't path to Style Sheet using ~

Can't path to Style Sheet using ~

Scheduled Pinned Locked Moved ASP.NET
csscomhelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tim Featherston
    wrote on last edited by
    #1

    This code doesn't find the Style sheet: where the cardss.css is in the root of the web folder. I have used the ~ successfully in other areas such as <%@ Register...... Src="~/header.ascx" .....%> I am not allowed to use ../ to move up levels. I don't understand why the tilde is not working. I don't get an error, I just don't have any of the formatting. TF Tim Featherston www.QBSix.com

    S 1 Reply Last reply
    0
    • T Tim Featherston

      This code doesn't find the Style sheet: where the cardss.css is in the root of the web folder. I have used the ~ successfully in other areas such as <%@ Register...... Src="~/header.ascx" .....%> I am not allowed to use ../ to move up levels. I don't understand why the tilde is not working. I don't get an error, I just don't have any of the formatting. TF Tim Featherston www.QBSix.com

      S Offline
      S Offline
      Steven Campbell
      wrote on last edited by
      #2

      The ~ only works for server-side paths, and is translated to an actual path before sending to the browser. Since your link tag is plain client side HTML, it is sent to the browser as-is. On some tags, you can add runat="server" to make it a server-side control, thus enabling the ~. I do not know if it will work with the link tag though.


      my blog

      T 1 Reply Last reply
      0
      • S Steven Campbell

        The ~ only works for server-side paths, and is translated to an actual path before sending to the browser. Since your link tag is plain client side HTML, it is sent to the browser as-is. On some tags, you can add runat="server" to make it a server-side control, thus enabling the ~. I do not know if it will work with the link tag though.


        my blog

        T Offline
        T Offline
        Tim Featherston
        wrote on last edited by
        #3

        No, the runat="server" doesn't work within the link tag. No error, jsut nothing happens. I'm confused, because the web hosting practice where I am taking this don't allow ../ logic. I have been reading web security papers this week, and it appears that is the direction sites are going to. If so, how do you reference /cardss.css from /aFolder/oneLevel/aPage.aspx ? All of my web experience has been in the middle (data services) and db tiers, so I am fighting the learnign curve for presentation development. Thanks for you comments. TF Tim Featherston www.QBSix.com

        S 1 Reply Last reply
        0
        • T Tim Featherston

          No, the runat="server" doesn't work within the link tag. No error, jsut nothing happens. I'm confused, because the web hosting practice where I am taking this don't allow ../ logic. I have been reading web security papers this week, and it appears that is the direction sites are going to. If so, how do you reference /cardss.css from /aFolder/oneLevel/aPage.aspx ? All of my web experience has been in the middle (data services) and db tiers, so I am fighting the learnign curve for presentation development. Thanks for you comments. TF Tim Featherston www.QBSix.com

          S Offline
          S Offline
          Steven Campbell
          wrote on last edited by
          #4

          I have never heard of a web hosting practice with a policy like this, and I have no idea how they would even enforce it. Using ../ is pretty standard, even recommended. The only other way is to use an absolute path, i.e. something that begins with /, or the actual host name. In fact, even should you succeed in using the ~, it may be rendered as ../ on the browser. I can understand wanting to avoid ../ on user controls (because they can be used in different directories), but not on normal pages.


          my blog

          T 1 Reply Last reply
          0
          • S Steven Campbell

            I have never heard of a web hosting practice with a policy like this, and I have no idea how they would even enforce it. Using ../ is pretty standard, even recommended. The only other way is to use an absolute path, i.e. something that begins with /, or the actual host name. In fact, even should you succeed in using the ~, it may be rendered as ../ on the browser. I can understand wanting to avoid ../ on user controls (because they can be used in different directories), but not on normal pages.


            my blog

            T Offline
            T Offline
            Tim Featherston
            wrote on last edited by
            #5

            IN IIS 6.0, there is a property "Allow "../" which by default is unchecked. I think in IIS 5.0, you accomplish this with a Microsoft tool called URLScan, which runs as an ISAPI filter. This web application will be running on the military secured network. You are correct. The ~ is rendered as a ../ on the browser if you view source. The following is an excerpt from Improving Web Application Security Patterns And Practices from Microsoft. Arbitrary Code Execution If an attacker can execute malicious code on your server, the attacker can either compromise server resources or mount further attacks against downstream systems. The risks posed by arbitrary code execution increase if the server process under which the attacker’s code runs is over-privileged. Common vulnerabilities include weak IID configuration and unpatched servers that allow path traversal and buffer overflow attacks, both of which can lead to arbitrary code execution. Countermeasures to help prevent arbitrary code execution include: ● Configure IIS to reject URLs with “../” to prevent path traversal. ● Lock down system commands and utilities with restricted ACLs. ● Stay current with patches and updates to ensure that newly discovered buffer overflows are speedily patched. Maybe ~ is OK because that is server side ? Like I said, I am pretty weak in this area. I appreciate your comments. TF Tim Featherston www.QBSix.com

            S 1 Reply Last reply
            0
            • T Tim Featherston

              IN IIS 6.0, there is a property "Allow "../" which by default is unchecked. I think in IIS 5.0, you accomplish this with a Microsoft tool called URLScan, which runs as an ISAPI filter. This web application will be running on the military secured network. You are correct. The ~ is rendered as a ../ on the browser if you view source. The following is an excerpt from Improving Web Application Security Patterns And Practices from Microsoft. Arbitrary Code Execution If an attacker can execute malicious code on your server, the attacker can either compromise server resources or mount further attacks against downstream systems. The risks posed by arbitrary code execution increase if the server process under which the attacker’s code runs is over-privileged. Common vulnerabilities include weak IID configuration and unpatched servers that allow path traversal and buffer overflow attacks, both of which can lead to arbitrary code execution. Countermeasures to help prevent arbitrary code execution include: ● Configure IIS to reject URLs with “../” to prevent path traversal. ● Lock down system commands and utilities with restricted ACLs. ● Stay current with patches and updates to ensure that newly discovered buffer overflows are speedily patched. Maybe ~ is OK because that is server side ? Like I said, I am pretty weak in this area. I appreciate your comments. TF Tim Featherston www.QBSix.com

              S Offline
              S Offline
              Steven Campbell
              wrote on last edited by
              #6

              Ah, now I understand. I think that restriction only applies to server side "include" files, and to normal server paths -- the following would be illegal: <!--#include file="../filename.ext"--> as would http://myserver/abc.def.ghi/myfile.aspx but it should still be ok to use normal client-side relative file references, like your CSS file, or an image file.


              my blog

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups