Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jason Evans 50 posts 71 karma points
    Nov 07, 2012 @ 18:15
    Jason Evans
    0

    Forms Authentication - Login.aspx page has not styling applied.

    In the web.config settings for our site, we have the following defined for authentication:

     

    <authentication mode="Forms">
          <forms name="yourAuthCookie" loginUrl="login.aspx" protection="All" path="/" timeout="1440" />
        </authentication>
        <authorization>
          <deny users="?" />
        </authorization>

    The idea is to stop anonymous users from accessing any pages in the site until the login.

    Now when I navigate to a page on the site, as a non-authenticated user, I'm redirected to the "login.aspx" page. However, the page  contains no styling at all, just the basic HTML layout.

    After I login, I then manually navigate to the "logout.aspx" page and log myself out. In doing this, I'm redirected to the site's login page. This time the page does look styled and formatted as expected.

    I did a network trace of each scenario. First, here's an edited summary of the "login.aspx" navigation:

     

    http://mysite/login.aspx?ReturnUrl=%2f..
    /css/default.css GET 302 text/html
    /css/global.css GET 302 text/html
    /css/login.css GET 302 text/html
    /media/5908/banner_990x120.jpg GET 302
    /WebResource.axd?d=bMvcbgLvBw-b3D3oyaWt6VZHcbfojD7MZsUlWMNFVmEWIq8MwwoMXtKRf9M-ARilE3OzwI_vfxdOOM4NZb1JL9Xs3AKQszOFDkYEg_-IpSY1&t=634773866700000000 GET 200 application/x-javascript 22.12 KB 62 ms <script> 47 0 16 46 0 189
    /WebResource.axd?d=Ad0N2sqdv93IoR4fGfJvpHQdOl24DoWfwQ_Uh6fucSzpRKc8V71tvjYUS9cp84q57vjyux3ocoK3CYIbGKwazdMLT8Bjwcg7SWzerLtQ4701&t=634773866700000000 GET 200 application/x-javascript 26.62 KB 94 ms <script> 47 0 16 78 0 157
    /media/448/logo_55.jpg GET 302 text/html 302 B 94 ms <img> 47 62 32 0 0 157
    /login.aspx?ReturnUrl=%2fcss%2fglobal.css GET 200 text/html
    /login.aspx?ReturnUrl=%2fcss%2fdefault.css GET 200 text/html
    /login.aspx?ReturnUrl=%2fmedia%2f5908%2fbanner_990x120.jpg GET 200 text/html
    /login.aspx?ReturnUrl=%2fcss%2flogin.css GET 200 text/html
    /login.aspx?ReturnUrl=%2fmedia%2f448%2flogo_55.jpg GET 200

     

    Here is the edit trace for the "login.aspx" which I was redirected to after loggin out:

    /  GET  302  text/html
    http://mysite/login.aspx?ReturnUrl=%2f GET 200 text/html
    /css/default.css GET 304 text/css
    /css/global.css GET 304 text/css
    /css/login.css GET 302 text/html
    /WebResource.axd?d=bMvcbgLvBw-b3D3oyaWt6VZHcbfojD7MZsUlWMNFVmEWIq8MwwoMXtKRf9M-ARilE3OzwI_vfxdOOM4NZb1JL9Xs3AKQszOFDkYEg_-IpSY1&t=634773866700000000 GET 304 application/x-javascript 220 B < 1 ms <script> 47 0 0 0 0 141
    /WebResource.axd?d=Ad0N2sqdv93IoR4fGfJvpHQdOl24DoWfwQ_Uh6fucSzpRKc8V71tvjYUS9cp84q57vjyux3ocoK3CYIbGKwazdMLT8Bjwcg7SWzerLtQ4701&t=634773866700000000 GET 304 application/x-javascript 220 B < 1 ms <script> 47 0 0 0 0 141
    /login.aspx?ReturnUrl=%2fcss%2flogin.css GET 200 text/html

    There is a difference between the two, and I'm asking for help from someone who can explain how I should configure my site, so that the login.aspx page looks as it should, regardless of how it is accessed.

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Nov 08, 2012 @ 12:37
    Peter Gregory
    0

    What version of Umbraco are you working with?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Nov 08, 2012 @ 12:42
    Matt Brailsford
    0

    Hi Jason,

    It looks like the forms auth is also securing your css / images folder for some reason.

    You can add overrides for the css / images / etc folders to allow anonymous access by adding the following to your web.config

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

    So for each location, add one of those blocks and just set the path accordingly.

    Alternatively, if you are just creating a regular umbraco site, ie, aren't integrating with anything else, you could set that back to the default, and just use thep ublic access feature instead? This is baked into umbraco so in the back office, if you set a section of the site to be protected (right click the node, and choose public access) it'll block people from accessing it untill authenticated.

    Hope this helps.

    Matt

  • Jason Evans 50 posts 71 karma points
    Nov 08, 2012 @ 12:45
    Jason Evans
    0

    @Peter - We are currently using Umbraco version 4.7.2

    @Matt - Thanks for that suggestion. I'm going to have a look at applying it now, will let you guys know how it works out :)

  • Jason Evans 50 posts 71 karma points
    Nov 08, 2012 @ 13:04
    Jason Evans
    0

    I'm altering the web.config file to include location specific security configs like so:

     

    <configuration>

     <location path="~/css">

       <system.web>

    <authorization>

    <allow users="*"/>

    </authorization>

    </system.web>

    </location>

      <configSections>

    ... rest of file

     

     

    When I navigate to the site I get the following error:

     

    HTTP Error 500.19 - Internal Server Error
    The requested page cannot be accessed because the related configuration data for the page is invalid.

    The error page has the <configSections> element highlighted in red, so it doesn't like the <location> element being next to it (?).

    I've Google'd around on how to use the <location> element and I can't see what I'm doing wrong - there's no mention of not allowed to put a <location> element next to the <configSections>.

    Can anyone help please?

     

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Nov 08, 2012 @ 13:07
    Matt Brailsford
    0

    Maybe try setting the path to ~/css/* and if that doesn't work, maybe try removing the tilda

    Matt

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Nov 08, 2012 @ 13:09
    Peter Gregory
    0

    This is the default setting for Umbraco.  You currently have it set to deny... change it to allow.  I assume you are using the public access features of Umbraco?

    <authentication mode="Forms">
          <forms name="yourAuthCookie" timeout="1440" loginUrl="login.aspx" protection="All" path="/" />
        </authentication>
        <authorization>
          <allow users="?" />
        </authorization>
  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Nov 08, 2012 @ 13:16
    Peter Gregory
    0

    Let me qualify my last post and how I would make it work to achieve what you are after.

    To deny access to the site, set the public access to the member group that you want on the root of the tree.  You will have to have your login outside of main tree because you need to be able to access it.

    so make the tree looked something like this.

    Content
    |-Home (protected with public access to the group you want to give access)
    | |-all the sub pages will be protected
    | |-etc etc etc
    |-Login (outside the home tree and not protected) 

    This will stop Annoymous access but you will have access to images and CSS as you are not explicitly denying access but denying based on configuration in Umbraco.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Nov 08, 2012 @ 13:20
    Matt Brailsford
    0

    I would agree with Peter that this is the better / umbraco way to do it.

    The only time I would think you would need to do what you are currently doing, is if you were integrating with someother .NET app on the same install. In which case, the location element should be what you need.

    Matt

  • Jason Evans 50 posts 71 karma points
    Nov 08, 2012 @ 14:28
    Jason Evans
    0

    The (simplified) structure of the site is like this:

     

    Content
    |-Site1
    |-LoginPage  
    |-Site2
    |-Site3

     

    So we want to allow anyone access to the Login page, but all the sites (Site1, Site2, etc) should only be accessible to logged in users.

    Can someone suggest how we could configure this in web.config please?

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Nov 08, 2012 @ 14:34
    Peter Gregory
    0

    @Jason 

    Go with the solution that I suggested and change the web.config to this.

    <authenticationmode="Forms">
         
    <formsname="yourAuthCookie"timeout="1440"loginUrl="login.aspx"protection="All"path="/"/>
       
    </authentication>
       
    <authorization>
         
    <allowusers="?"/>
       
    </authorization>

    Then follow the instructions that are on this wiki page that explains how public access works.

    http://our.umbraco.org/wiki/reference/umbraco-client/context-menus/public-access

    I think this will sort your issues out.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Nov 08, 2012 @ 14:35
    Matt Brailsford
    0

    I agree with @peter, I think using public access is the way to go. This linke might also help 

    http://www.mortenbock.dk/blog/2009/04/01/setting-up-membership-in-umbraco.aspx

    Matt

  • Jason Evans 50 posts 71 karma points
    Nov 09, 2012 @ 13:10
    Jason Evans
    0

    A colleague of mine had a copy of access.config, which contained numerous permission setting configured. I got a copy of that file and tried it in my local version of the Umbraco site and it worked fine.

    As a anonymous user, I cannot view anything on the site until I've logged in. I remove the <deny users.... setting back to <allow.

    Many, many thanks for all your help with this. Much appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft