ASP.NET Forms Authentication prevents javascript loading on Login.aspx

I'm having trouble authenticating with forms. When I try to load my Login.aspx page, neither javascript nor style sheets load. Here is part of my web.config file

        <authentication mode="Forms">
        <forms loginUrl="Login.aspx"
               timeout="30"
               name=".ASPXAUTH"
               path="/"
               requireSSL="false"
               slidingExpiration="true"
               defaultUrl="Main.aspx"
               cookieless="UseDeviceProfile" />
    </authentication>

    <authorization>
        <deny users="?" />
    </authorization>

Please help me understand what is happening.

+5
source share
2 answers

You need to add exceptions to these directories or files in your web.config under the element <configuration>.

<configuration>
  <system.web>
     ...
  </system.web>

  <location path="css">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>
+10
source

Post to Global.asax

Public Sub FormsAuthentication_OnAuthenticate(ByVal sender As Object, ByVal args As FormsAuthenticationEventArgs)
    If args.Context.Request.Path.EndsWith("js") Or args.Context.Request.Path.EndsWith("css") Then
        Dim ObjUser As WindowsIdentity = args.Context.Request.LogonUserIdentity
        Dim ObjPrincipal As WindowsPrincipal = New WindowsPrincipal(ObjUser)
        args.User = ObjPrincipal
    End If
End Sub
0
source

All Articles