Anonymous anonymously for all pages except the path "~ /" in asp.net

in asp.net, I use this configuration section to strip anonymous users of all pages.

<authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> <authorization> <deny users="?" /> </authorization> 

and I use the following to declare an exception that an anonymous user may call.

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

which is great for me.

however, how can I set only the default page as an exception? (for example: anonymous can only access http: // mysite / , but can’t access other pages on the site?)

i'v tried to use location path = "~ /" or "/" and it does not work.

+7
source share
2 answers

If path="Default.aspx" does not work, this cannot be done using the configuration. There is no syntax available to specify only the application root in the path attribute.

+3
source

I think you can change your directory structure to achieve this. Then you can change web.config to deny the user

 <configuration> <system.web> <authorization> <allow roles="administrators" /> <deny users="?" /> </authorization> </system.web> </configuration> 
0
source

All Articles