如何使用声明基础身份验证 [英] How to use claim base authentication
问题描述
您好,
我想使用基于声明的系统。我在button1上设置了索赔值但是我没有在button2上获得值。
你能否帮我在button2或其他页面上获取索赔值。
提前致谢!
Button1 - 设定索赔价值
var claim = new 列表< Claim> ();
claims.Add( new Claim(ClaimTypes.Name, 用户名跨度>));
claims.Add( new Claim(ClaimTypes.Sid, 11跨度>));
claims.Add( new Claim(ClaimTypes.Role, Admin));
Button2:获取索赔价值
?
我尝试过:
使用System.Security.Claims;
protected void btnSet_Click(object sender,EventArgs e)
{
lblmsg.Text =;
var claims = new List< claim>();
claims.Add(new Claim(ClaimTypes.Name,user.FirstName user.LastName));
Claims.Add(new Claim(ClaimTypes.Sid,11));
claims.Add(new Claim(ClaimTypes.Role,Admin));
}
protected void btnGet_Click(object sender,EventArgs e)
{
lblmsg.Text = claim.Value;
}
让我为你做谷歌 [ ^
Hello,
I want to use claim based system. I have set claim value on button1 BUT not I am not getting values on button2.
Can you please help me to get claim value on button2 or in another page.
Thanks in Advance !
Button1 - Set claim Value
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, "Username"));
claims.Add(new Claim(ClaimTypes.Sid, "11"));
claims.Add(new Claim(ClaimTypes.Role, "Admin"));
Button2: Get claim Value
?
What I have tried:
using System.Security.Claims;
protected void btnSet_Click(object sender, EventArgs e)
{
lblmsg.Text = "";
var claims = new List<claim>();
claims.Add(new Claim(ClaimTypes.Name, "user.FirstName user.LastName"));
claims.Add(new Claim(ClaimTypes.Sid, "11"));
claims.Add(new Claim(ClaimTypes.Role, "Admin"));
}
protected void btnGet_Click(object sender, EventArgs e)
{
lblmsg.Text = claim.Value;
}
Let me google that for you[^]
这篇关于如何使用声明基础身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!