The ?
wildcard represents unauthenticated users while *
represents all users, authenticated and unauthenticated. My book shows the following example of URL authorization:
<authorization> <deny users="?" /> <allow users="dan,matthew" /> <deny users="*" /> </authorization>
But doesn’t the above code have the same effect as :
<authorization> <allow users="dan,matthew" /> <deny users="*" /> </authorization>
or did the author also include <deny users="?" />
rule for a reason?
means deny unauthenticated users. The deny element adds to the mapping of authorization rules that is stored in the authorization element an authorization rule that denies access to a resource. This is the case when you want everybody to login before the can start browsing around your website.
You can configure the <authorization> element at the server level in the ApplicationHost. config file, or at the site or application level in the appropriate Web. config file. You can set default authorization rules for the entire server by configuring authorization rules at the server level.
ASP.NET grants access from the configuration file as a matter of precedence. In case of a potential conflict, the first occurring grant takes precedence. So,
deny user="?"
denies access to the anonymous user. Then
allow users="dan,matthew"
grants access to that user. Finally, it denies access to everyone. This shakes out as everyone except dan,matthew is denied access.
Edited to add: and as @Deviant points out, denying access to unauthenticated is pointless, since the last entry includes unauthenticated as well. A good blog entry discussing this topic can be found at: Guru Sarkar's Blog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With