This is a small Html helper that I use when I need to check the role in a view
public static class PageHelper
{
public static bool IsAdmin(this ViewUserControl pg)
{
return pg.Page.User.IsInRole("Admin");
}
public static bool IsCustomer(this ViewUserControl pg)
{
return pg.Page.User.IsInRole("Customer");
}
}Don't forget to add the namespace for your extension methods in your Web.config :<namespaces> <add namespace="MyProject.Web.Helpers" /> </namespaces>
Aucun commentaire:
Enregistrer un commentaire