我在WebApi2项目中收到以下错误:
无法加载文件或程序集'System.IdentityModel.Tokens.Jwt,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
我安装了这些相关的NuGet包以及其他一些包:
"Microsoft.IdentityModel.Protocol.Extensions"version ="1.0.2.206221351"targetFramework ="net45"
"Microsoft.Owin"version ="3.0.1"targetFramework ="net45"
"Microsoft.Owin.Host.SystemWeb"version ="3.0.1"targetFramework ="net45"
"Microsoft.Owin.Security"version ="3.0.1"targetFramework ="net45"
"Microsoft.Owin.Security.ActiveDirectory"version ="3.0.1"targetFramework ="net45"
"Microsoft.Owin.Security.Jwt"version ="3.0.1"targetFramework ="net45"
"Microsoft.Owin.Security.OAuth"version ="3.0.1"targetFramework ="net45"
"System.IdentityModel.Tokens.Jwt"version ="4.0.2.206221351"targetFramework ="net45"
顺便说一下,我的web.config中也有以下绑定重定向,但它仍然试图加载4.0版本.
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.20622.1351" newVersion="4.0.20622.1351" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
任何有关故障排除的帮助将非常感谢.
我遵循以下GitHub示例,以实现跨WebApp和WebApi的身份验证机制.
https://github.com/AzureADSamples/WebApp-WebAPI-OpenIDConnect-DotNet
我正在为WebApp和WebApi使用单个App注册,获取" https://abc.onmicrosoft.com/App " 的访问令牌并将其传递给WebApi.我将令牌附加到名为"Bearer"的HTTPS标头.我在WebApi Owin Startup类中有以下内容来验证Audience和Tenant的令牌,但实际上并未按预期验证令牌.
几个问题:1.什么触发下面的处理程序来验证租户和受众的令牌?它是Controller类的[Authorize]属性吗?2.如何找到执行处理程序的令牌?3.将SaveSigninToken设置为true可保存令牌.如何检索令牌并从此令牌获取Graph API的访问令牌?
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = "abc.onmicrosoft.com",
TokenValidationParameters = new TokenValidationParameters
{
ValidAudience = "https://abc.onmicrosoft.com/App",
SaveSigninToken = true,
}
});
Run Code Online (Sandbox Code Playgroud)
请指教.提前致谢!
C#Selenium如何实现没有id的点击按钮
这是html:
<div class="fe-margin">
<button class="btn btn-default" data-bind="click: $root.addParameter, enable: $root.selectedParameter() == null" type="button"/>
Add parameter button
</div>
Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的对象
public class SampleObject
{
public int MsfId { get; set; }
public List<string> PgId { get; set; }
public List<string> DcId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在以上聚合的PgId值的聚合中MsfId.情况DcId也是如此.
例如:
MsfId: 100
PgId: "abc"
DcId: "123"
MsfId: 100
PgId: "def"
DcId: "456"
MsfId: 100
PgId: "ghi"
DcId: "789"
MsfId: 101
PgId: "abc"
DcId: "123"
Run Code Online (Sandbox Code Playgroud)
如何编写LINQ查询来聚合它并创建一个SampleObjects列表,如下所示?
MsfId: 100
PgId: "abc", "def", "ghi"
DcId: "123", "456", "789"
MsfId: 101
PgId: "abc"
DcId: "123"
Run Code Online (Sandbox Code Playgroud) HttpContext.Current在等待调用后在异步中为null。
这是我的代码:
if (!string.IsNullOrEmpty(securityGroupName))
{
// To remove the domain name from the security group name.
string securityGroupDisplayName = securityGroupName.Split('\\')[1];
string serviceSecurityGroupId = await this.graphApiClient.GetGroupIdAsync(securityGroupDisplayName).ConfigureAwait(false);
if (!string.IsNullOrEmpty(serviceSecurityGroupId))
{
Task securityGroupRoleAddTask = this.CheckMembershipAndAddRole(serviceSecurityGroupId, userId, securityGroupName);
Task flightAdminRoleAddTask = this.CheckMembershipAndAddRole(FlightAdminSecurityGroupId, userId, FlightAdminRoleName);
Task.WaitAll(securityGroupRoleAddTask, flightAdminRoleAddTask);
}
else
{
LoggingUtilities.Logger.TraceInformation("Azure AD id does not exist for the security group: {0}.", securityGroupName);
await this.CheckMembershipAndAddRole(FlightAdminSecurityGroupId, userId, FlightAdminRoleName).ConfigureAwait(false);
}
}
else
{
LoggingUtilities.Logger.TraceInformation("Security group name is not valid, checking for flight admin role for the user: {0}.", …Run Code Online (Sandbox Code Playgroud)