NOTE: If you are using Microsoft Visual C# .NET, the following syntax accesses this variable:
- Change the authentication mode in the Web.config file to anything other than None. For example, the following entry in the Web.config file sets the authentication mode to Forms-based authentication:
<authentication mode="Forms" />
- To deny access to the Anonymous user in the Web.config file, use the following syntax:
<deny users = "?" /> <!-- This denies access to the Anonymous user -->
<allow users ="*" /> <!-- This allows access to all users -->
- Change the authentication mode in the Web.config file to Windows as follows:
<authentication mode="Windows" />
- In the Internet Services Manager, right-click the .aspx file or the Web Project folder, and then click Properties.
- If you clicked Properties for the Web Project folder, click the Directory Security tab. If you clicked Properties for the .aspx file, click the File Security tab.
- Under Anonymous Access and authentication control, click Edit.
- In the Authentication methods dialog box, clear the Anonymous Access check box, and then select either the Basic, the Digest or the Integrated (NT Challenge/Response) check box.
- Click OK to close both dialog boxes.
NOTE: When you enable Anonymous authentication in conjunction with Windows authentication or if you grant access to the Anonymous user in the <authorization> section while you are using any authentication mode other than None, other server variables such as AUTH_USER and REMOTE_USER (as well as the HttpContext.Current.User.Identity.Name property) also return an empty string. You can use the any of the above-mentioned resolutions to populate these variables.
In ASP.NET, you can also use the IsAuthenticated property of the Request object to determine whether the Anonymous Access security is being used. IsAuthenticated returns "false" if Anonymous Access is turned on and returns "true" if you use any other means of authentication such as Forms, Passport, Integrated (NT Challenge/Response), or Basic.
Article ID: 306359 - Last Review: May 21, 2009 - Revision: 1