Previously I had shown how to...
DataTables in MVC:
- Code First Migrations in MVC 5
- Jquery DataTable in MVC
- Jquery DataTable multisearch paging and Sorting in MVC server side
- Jquery DataTable paging, Sorting and Multi search with datepicker in MVC server side
- Cascading DropDowns in Asp.Net MVC
- AngularJS with Web Api in Asp.net MVC using Token based Authentication
- Ajax helper Based Search in MVC
AngularJS:
- Two way Binding in AngularJS
- Simple Routing in AngularJS
- Datatables in AngularJS and asp.net mvc
- Datatables Column Filter with AngularJS and asp.net mvc
- Datatable Exporting with AngularJS and asp.net mvc
By creating a CustomAuthorize class which inherits AuthorizeAttribute we can redirect the user to home page instead of a login page.
How to use?
How to use?
[CustomAuthorize(Roles = "Admin")]
public ActionResult Index()
{
return View();
}
public class CustomAuthorize : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
if (!filterContext.HttpContext.Request.IsAuthenticated)
{
base.HandleUnauthorizedRequest(filterContext);
}
else
{
filterContext.Result = new RedirectToRouteResult(new
RouteValueDictionary(new { controller = "Home", action = "Index" }));
}
}
}
No comments:
Post a Comment