I am experiencing problems with Forms Authentication. When I try to load my Login.aspx page neither javascript nor stylesheets do not 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>
Help me, please, to understand what’s happening.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You need to add exceptions to those directories or files in your web.config, underneath the <configuration> element.
<configuration>
<system.web>
...
</system.web>
<location path="css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
Method 2
Put in 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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0