I remember, that I used to get Logged In user ID(for Intranet Application) using the following code:-
string WindowsLoginID= System.Web.HttpContext.Current.Request.ServerVariables["AUTH_USER"];// This is blank
It still works fine when I use it in code behind of ASP application.
But when I am using the same code in MVC4 Application
it is returning me blank
.
I am running my project as Use Local IIS Web Server
and my web.config I have-
<authentication mode="Windows">
</authentication>
Please let me know, If I am doing some thing silly.
I was missing some configuration, I created a New MVC Intranet Application and did the setting changes as follows:-
Hosting on IIS Express:
In the Properties pane for your project:
a) Set "Anonymous Authentication" to "Disabled".
b) Set "Windows Authentication" to "Enabled".
Hosting on IIS 7 or later:
On the Authentication page, select Windows authentication. If Windows authentication is not an option, you'll need to make sure Windows authentication is installed on the server.
To enable Windows authentication on Windows:
a) In Control Panel open "Programs and Features".
b) Select "Turn Windows features on or off".
c) Navigate to Internet Information Services > World Wide Web Services > Security and make sure the Windows authentication node is checked.
To enable Windows authentication on Windows Server:
a) In Server Manager, select Web Server (IIS) and click Add Role Services.
b) Navigate to Web Server > Security and make sure the Windows authentication node is checked.
In the Actions pane, click Enable to use Windows authentication.
Source:- readme.txt of MVC Intranet Application
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