@if(HttpContext.User.HasClaim("User","Delete"))
{
<input type='button' value="删除"/>
}
<a asp-claim="goods,edit" asp-action="addgoods" asp-route-id="@goods.Id" class="btn-icon " title="编辑"><i class="icon-common-edit icon-pencil"></i></a>
class ClaimTagHelper:TagHelper
{
private const string ClaimAttributeName = "asp-claim";
public ClaimTagHelper()
{
}
[HtmlAttributeName(ClaimAttributeName)]
public string Claim { get; set; }
}
[HtmlTargetElement("a", Attributes = ClaimAttributeName)]
[HtmlTargetElement("button", Attributes = ClaimAttributeName)]
[HtmlTargetElement("input", Attributes = ClaimAttributeName, TagStructure = TagStructure.WithoutEndTag)]
public class ClaimTagHelper: TagHelper
{
......
}
public class ClaimTagHelper: TagHelper
{
.....
[HtmlAttributeNotBound]
[ViewContext]
public ViewContext ViewContext { get; set; }
.....
}
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (string.IsNullOrEmpty(Claim))
{
return;
}
string[] claimData = Claim.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
if (claimData.Length == 1)
{
if (!ViewContext.HttpContext.User.HasClaim(m => m.Type == claimData[0]))
{
//无权限
output.SuppressOutput();
}
}
else
{
if (!ViewContext.HttpContext.User.HasClaim(m => m.Type == claimData[0] && m.Value == claimData[1]))
{
//无权限
output.SuppressOutput();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有