虽然安装System.IdentityModel.Tokens JWTSecurityTokenHandler和SecurityTokenDescriptor甚至没有发现并使用

编程入门 行业动态 更新时间:2024-10-20 16:47:55
本文介绍了虽然安装System.IdentityModel.Tokens JWTSecurityTokenHandler和SecurityTokenDescriptor甚至没有发现并使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图写来生成.NET C#JWT令牌的方法。通过互联网搜索,我发现演示如何做到这一点的页面。我下面一个这样的网页是 gist.github/pmhsfelix/4151369 。为了支持这一点,我在包管理器控制台跑安装封装System.IdentityModel.Tokens.Jwt ,可以看到<包ID在我paackages.config =System.IdentityModel.Tokens.Jwt版本=4.0.2.205111437targetFramework =net45/>。但尽管如此,该SecurityTokenDescriptor找不到。我有一个强烈的感觉,实在是有些版本不匹配,但我不能找出它是什么。有人可以帮我解决这个问题。

I am trying to write a method to generate JWT token in C#. Searching through internet I found pages demonstrating how do do this. One such page I am following is gist.github/pmhsfelix/4151369. To support this, I ran "Install-Package System.IdentityModel.Tokens.Jwt" in the package manager console and can see "<package id="System.IdentityModel.Tokens.Jwt" version="4.0.2.205111437" targetFramework="net45" />" in my paackages.config. But still, the SecurityTokenDescriptor is not found. I have a strong feeling it is some version mismatch but I am not able to find out what is it. Can some one help me fix this?

推荐答案

确认,在你的代码中使用:

Make sure that in your code you use:

using System.IdentityModel.Tokens; using Microsoft.IdentityModel;

另外,我相信你将需要添加一个引用:

Also, I believe you will need to add a reference to:

System.IdentityModel

..这是在Visual Studio大会选项卡中找到。

.. which is found in the Assemblies tab in Visual Studio.

希望这可以帮助你。

更多推荐

虽然安装System.IdentityModel.Tokens JWTSecurityTokenHandler和SecurityTokenDescriptor甚

本文发布于:2023-11-13 00:17:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582884.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发现   IdentityModel   System   Tokens   SecurityTokenDescriptor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!