Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




ASP.NET MVC interview questions: - How to implement windows authentication for MVC?

For windows authentication you need to go and modify the “web.config” file and set authentication mode to windows.

<authentication mode="Windows"/>

<authorization>

<deny users="?"/>

</authorization>

Then in the controller or on the action you can use the “Authorize” attribute which specifies which users have access to these controllers and actions. Below is the code snippet for the same. Now only the users specified in the controller and action can access the same.

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

    public class StartController : Controller

    {

        //

        // GET: /Start/

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

        public ActionResult Index()

        {

            return View("MyView");

        }

 

    }

Above is the ASP.NET MVC interview questions & also see the following video on redirect permanent: -

Helpful Website Url
http://www.questpond.com/
Share this article   |    Print    |    Article read by 4826 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles:
Related Interview Questions: No related interview question