草庐IT

express-jwt

全部标签

c# - 修改 OWIN OAuth 中间件以使用 JWT 不记名 token

我目前正在尝试使用以下技术的组合为新应用创建基于声明的身份验证的概念证明:WebAPI2、OWIN中间件和JWT。为了简单起见,我从WebAPI2项目模板开始并将身份验证更改为“个人用户帐户”。然后,我创建的示例客户端能够通过调用/Token获取token,并能够使用OAuth持有者token调用示例端点。到目前为止,一切都很好。然后我将以下代码添加到Startup.Auth.cs以尝试启用JwtBearerAuthentication:varjwtOptions=newJwtBearerAuthenticationOptions{AllowedAudiences=audiences,

c# - Linq 和相等运算符 : Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object'

我试图重写C#中的相等(==)运算符来处理任何类型与自定义类型的比较(自定义类型实际上是null周围的包装器/框)。所以我有这个:internalsealedclassNothing{publicoverrideboolEquals(objectobj){if(obj==null||objisNothing)returntrue;elsereturnfalse;}publicstaticbooloperator==(objectx,Nothingy){if((x==null||xisNothing)&&(y==null||yisNothing))returntrue;returnfal

c# - 林克 "Could not translate expression... into SQL and could not treat it as a local expression."

我从thisquestion开始,我有点回答there,现在我在这里问更基本的问题。我已将查询简化为:varq=fromentinLinqUtils.GetTable()fromtelinent.Telephones.DefaultIfEmpty()selectnew{Name=ent.FormattedName,Tel=tel!=null?tel.FormattedNumber:""//thisiswhatcausestheerror};tel.FormattedNumber是一种将Number和Extension字段组合成格式整齐的字符串的属性。这是导致的错误:System.Inv

c# - EF lambda : The Include path expression must refer to a navigation property

这个问题在这里已经有了答案:EF:Includewithwhereclause[duplicate](5个答案)关闭5年前。这是我的表达:Coursecourse=db.Courses.Include(i=>i.Modules.Where(m=>m.IsDeleted==false).Select(s=>s.Chapters.Where(c=>c.IsDeleted==false))).Include(i=>i.Lab).Single(x=>x.Id==id);我知道原因是模块部分的Where(m=>m.IsDeleted==false),但为什么会导致错误?更重要的是,我该如何修复它

c# - 找不到部分路径 'C:\Program Files (x86)\IIS Express\~\TextFiles\ActiveUsers.txt'

我尝试了多种方法从名为TextFiles的文件夹访问我的VisualStudio2012解决方案中的文本文件using(System.IO.StreamWriterfile=newSystem.IO.StreamWriter(@"~/TextFiles/ActiveUsers.txt",true)){file.WriteLine(model.UserName.ToString());}但是一直报错Couldnotfindapartofthepath'C:\ProgramFiles(x86)\IISExpress\~\TextFiles\ActiveUsers.txt'.不知道哪里错了

c# - 如何验证 JWT token

我正在尝试使用JWTtoken。我设法生成了一个有效的JWTTokenString并在JWTdebugger上对其进行了验证但我无法在.Net中验证token。这是我到目前为止的代码:classProgram{staticstringkey="401b09eab3c013d4ca54922bb802bec8fd5318192b0a75f201d8b3727429090fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f5a65ed1";staticvoidMain(string[]args){varstringToken=

c# - 在 Visual C# 2008 Express Edition 中设置 32 位 x86 构建目标?

我正在构建一个加载32位COMdll的C#应用程序。编译后的应用程序在32位Windows上运行良好,但在64位Windows上运行失败,因为它无法加载32位COM。有没有办法在VC#2008ExpressEdition中设置32位构建目标?或者,是否有办法强制编译为AnyCPU构建目标的.NET应用程序在64位Windows上以32位模式运行? 最佳答案 为了后代,这里是adrian链接到的论坛帖子:InVC#Express,thispropertyismissing,butyoucanstillcreateanx86config

c# - 在 System.Linq.Expressions 中不带大小写(但使用默认值)切换

我尝试使用System.Linq.Expressions创建一个switch表达式:varvalue=Expression.Parameter(typeof(int));vardefaultBody=Expression.Constant(0);varcases1=new[]{Expression.SwitchCase(Expression.Constant(1),Expression.Constant(1)),};varcases2=newSwitchCase[0];varswitch1=Expression.Switch(value,defaultBody,cases1);vars

c# - 验证 JWT 签名时出现 SecurityTokenSignatureKeyNotFoundException

我正尝试为我的组织实现OpenIDConnect规范。我在测试依赖方应用程序中使用Microsoft的OpenIDConnectOWIN实现来验证我的协议(protocol)实现。我公开了以下元数据文档:{"issuer":"https://acs.contoso.com/","authorization_endpoint":"http://localhost:53615/oauth2/auth","token_endpoint":"http://localhost:53615/oauth2/token","userinfo_endpoint":"http://localhost:53

c# - 如何针对集合调用 Expression<Func<Entity, bool>>

我有一个从存储库模式定义存储库的接口(interface):interfaceIRepository{ListGetAllCustomers(Expression>expression);}我已经在EntityFramework上实现了它:classEntityFrameworkRepository{publicListGetAllCustomers(Expression>expression){returnDBContext.Customers.Where(expression).ToList();}}这似乎工作得很好,它允许我做类似的事情:varcustomers=entityFr