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. Forms Authentication - weird behavior

Forms Authentication - weird behavior

Scheduled Pinned Locked Moved ASP.NET
securitycsswpfhelpquestion
7 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.
  • M Offline
    M Offline
    Member 3919049
    wrote on last edited by
    #1

    I have create a website that has a Login.aspx page, a Default.aspx page and a DoSomething.aspx page. I have configured forms authentication in Web.config (pretty standard implementation) as follows: <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="10" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Login.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" /> </authentication> <authorization> <deny users="?" /> </authorization> When I run the website *without* Forms Authentication Login.aspx loads fine. When I run the website *with* Forms Authentication Login.aspx doesn't load any images or apply any styles referenced in the css files. Does this behavior sound familiar to anyone? What's the fix for this?

    D 1 Reply Last reply
    0
    • M Member 3919049

      I have create a website that has a Login.aspx page, a Default.aspx page and a DoSomething.aspx page. I have configured forms authentication in Web.config (pretty standard implementation) as follows: <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="10" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Login.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" /> </authentication> <authorization> <deny users="?" /> </authorization> When I run the website *without* Forms Authentication Login.aspx loads fine. When I run the website *with* Forms Authentication Login.aspx doesn't load any images or apply any styles referenced in the css files. Does this behavior sound familiar to anyone? What's the fix for this?

      D Offline
      D Offline
      Dimitri Witkowski
      wrote on last edited by
      #2

      You should allow loading images and styles to unauthorized users, this is a typical prcactice. By default, ASP.NET will require authorization for all files, including images. Something like:

      <location path="Images">
      <system.web>
      <authorization>
      <allow users="*"/>
      </authorization>
      </system.web>
      </location>

      <location path="css">
      <system.web>
      <authorization>
      <allow users="*"/>
      </authorization>
      </system.web>
      </location>

      Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

      M 2 Replies Last reply
      0
      • D Dimitri Witkowski

        You should allow loading images and styles to unauthorized users, this is a typical prcactice. By default, ASP.NET will require authorization for all files, including images. Something like:

        <location path="Images">
        <system.web>
        <authorization>
        <allow users="*"/>
        </authorization>
        </system.web>
        </location>

        <location path="css">
        <system.web>
        <authorization>
        <allow users="*"/>
        </authorization>
        </system.web>
        </location>

        Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

        M Offline
        M Offline
        Member 3919049
        wrote on last edited by
        #3

        Thanks! I'll try that. I don't think it was done that way in 1.1 was it?

        D 1 Reply Last reply
        0
        • M Member 3919049

          Thanks! I'll try that. I don't think it was done that way in 1.1 was it?

          D Offline
          D Offline
          Dimitri Witkowski
          wrote on last edited by
          #4

          Ohhh, I really don't remember how it was in 1.1 1.1 was soooooo long ago..

          Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

          1 Reply Last reply
          0
          • D Dimitri Witkowski

            You should allow loading images and styles to unauthorized users, this is a typical prcactice. By default, ASP.NET will require authorization for all files, including images. Something like:

            <location path="Images">
            <system.web>
            <authorization>
            <allow users="*"/>
            </authorization>
            </system.web>
            </location>

            <location path="css">
            <system.web>
            <authorization>
            <allow users="*"/>
            </authorization>
            </system.web>
            </location>

            Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

            M Offline
            M Offline
            Member 3919049
            wrote on last edited by
            #5

            Ok - I put the following config sections in my Web.config but I'm still getting the same behavior: <location path="images"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <location path="css"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> I tried: allow users="*" but it didn't work so I figured I'd try: allow users="?" since the images on the Login page will need to be displayed for unauthenticated users. The structure under my website is ./resources/images/myimage.jpg with a similar structure for the css directory. .NET wouldn't let me specify a path starting with "." or "/" or ending with "/" so I ended up using the config sections above. However, the images and styles still aren't displaying.

            D 1 Reply Last reply
            0
            • M Member 3919049

              Ok - I put the following config sections in my Web.config but I'm still getting the same behavior: <location path="images"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <location path="css"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> I tried: allow users="*" but it didn't work so I figured I'd try: allow users="?" since the images on the Login page will need to be displayed for unauthenticated users. The structure under my website is ./resources/images/myimage.jpg with a similar structure for the css directory. .NET wouldn't let me specify a path starting with "." or "/" or ending with "/" so I ended up using the config sections above. However, the images and styles still aren't displaying.

              D Offline
              D Offline
              Dimitri Witkowski
              wrote on last edited by
              #6

              No, you need "*", not "?". "*" is any user, including anonymous. "?" is anonymous. If the structure of your site is resources/images/myimage.jpg, you should add

              <location path="resources/images">

              Also, read about location element: http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx[^]

              Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

              M 1 Reply Last reply
              0
              • D Dimitri Witkowski

                No, you need "*", not "?". "*" is any user, including anonymous. "?" is anonymous. If the structure of your site is resources/images/myimage.jpg, you should add

                <location path="resources/images">

                Also, read about location element: http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx[^]

                Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

                M Offline
                M Offline
                Member 3919049
                wrote on last edited by
                #7

                Thanks! That worked.

                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