in MVC Language by
How to implement Windows authentication in MVC?

▼ Show 1 Answer

0 votes

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:

<authentication mode=”Windows”/>


<deny users=”?”/>


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.

[Authorize(Users= @”WIN-3LI600MWLQN\Administrator”)]

public class StartController : Controller



// GET: /Start/

[Authorize(Users = @”WIN-3LI600MWLQN\Administrator”)]

public ActionResult Index()


return View(“MyView”);



Learn More with Madanswer

Related questions

0 votes
asked Aug 18, 2019 in MVC Language by rahulsharma