You must Sign In to post a response.
  • Category: ASP.NET

    How to use claim base authentication

    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 !


    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;
    //Please help me here to get value
    }
  • #767119
    In order to authenticate a user, any browser must present a valid token at the application's gate. The token takes the form of a cookie or perhaps an authorization header such as in Basic, NTLM or Kerberos authentication
    look at below code
    it may help you better

    @if (Request.IsAuthenticated)
    {
    < ul class="nav navbar-right top-nav">
    < li class="dropdown">
    < a href="#" class="dropdown-toggle" data-toggle="dropdown">
    < span class="glyphicon glyphicon-user"></span>
    @currentUser.DisplayName <b class="caret"></b>
    < /a>
    < ul class="dropdown-menu">
    < li style="text-align: center">
    < img class="img-rounded"
    src="@currentUser.PictureUrl"
    onerror="this.src='/nophoto.png")'" />
    < br />
    @currentUser.Identity.Name:
    < strong>@currentUser.Role</strong>
    < /li>
    :
    }

    check out below link for more details
    https://www.simple-talk.com/dotnet/asp.net/handmade-claims-based-authentication-for-old-fashioned-asp.net-sites/

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments