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
0 comments:
Please let me know your view