Monday, 12 May 2014

How to implement windows authentication in asp.net mvc

5/12/2014 - By Pranav Singh 0

For securing your application with unauthorized access Microsoft have provided different type of authentication methods in your asp.net application, windows authentication is one of them. In this article we will learn to perform windows authentication.

For performing windows authentication in our MVC application first we will make configuration our application web.config file.

<authentication mode="Windows">
    </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>

Now in our controller end we will set attribute for authorizing the user type.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Windows_Authentication.Controllers
{      
   [Authorize (Users="@Administrator")]
   public class HomeController : Controller
    {
        //
        // GET: /Home/
        [Authorize (Users="@Administrator")]
        public ActionResult Index()
        {
            return View();
        }

    }
}


In above code we have provided user for authentication. We can perform both on controller as well as on action level.

Now for making IIS configuration for windows authentication follow the link

Tags: , , ,
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top