In some .NET projects, when you try to access the Request.ServerVariables (“LOGON_USER”) variable in ASP .NET, it will return an empty string. This problem will occur due to the related authentication variables in the Server Variables list are not populated if you are using Anonymous Access Security to access the page. In the
So how this problem can be solved?
There are two types of authentication mode which are Forms mode and Windows mode. To populate the LOGON_USER variable when you use any of the authentication mode other than none, you can deny access for Anonymous user in the
For authentication mode = “Forms”, use the following syntax in the Web.Config file.
< authorization >
< deny users = "?" > < !-- This denies access to the Anonymous user -- >
< allow users ="*" > < !-- This allows access to all users -- >
< /authorization >
If you are using Windows Authentication, go to Start > Run > Type inetmgr, this will bring IIS’s dialog box.
Expand Default Web Site and right click the Web Project folder, and then click Properties.
In the Properties dialog box, click the Directory Security tab, under the Anonymous access and authentication control, click Edit.
In the Authentication Methods dialog box, un-checked the Anonymous Access check box. Click OK for both dialog boxes. Close the IIS and does the testing again whether can get the value of LOGON_USER.
Hope this can help you work it out. Good luck.
0 comments:
Post a Comment