For Windows authentication, at first we need to change the web.config file and set the authentication mode to Windows. A sample code for that is given bellow:
Then in the controller or on the action, we can use the Authorize attribute which specifies which users have access to these controllers and actions. A sample code for that is given bellow, where only the user “Administrator” can access it.
public class StartController : Controller
// GET: /Start/
[Authorize(Users = @”WIN-3LI600MWLQN\Administrator”)]
public ActionResult Index()