1 Answer

0 votes
by

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”/>

<authorization>

<deny users=”?”/>

</authorization>

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”);

}

}

Related questions

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