最近我已将MVC项目中的软件包更新为4.0.0。 现在到现在为止,我能够解决此升级的很多问题(其他需要升级的软件包等)
但目前,我在这种例外情况上陷入困境:
Method not found: 'System.Func`2<Microsoft.Owin.Security.Notifications.MessageReceivedNotification`2<Microsoft.IdentityModel.Protocols.OpenIdConnectMessage,Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions>,System.Threading.Tasks.Task> Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationNotifications.get_MessageReceived()'.
我尝试过谷歌搜索,我尝试过在断点的类上设置一个断点(构造函数get被命中,但是引发异常的方法永远不会被命中)
任何人都知道下一步该怎么做?甚至在如何解决这个问题上更好?
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
{
if (Options.CallbackPath.HasValue && Options.CallbackPath != (Request.PathBase + Request.Path))
{
return null;
}
OpenIdConnectMessage openIdConnectMessage = null;
if (string.Equals(Request.Method, "POST", StringComparison.OrdinalIgnoreCase)
&& !string.IsNullOrWhiteSpace(Request.ContentType)
&& Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase)
&& Request.Body.CanRead)
{
if (!Request.Body.CanSeek)
{
//this._logger.WriteVerbose("Buffering request body");
// Buffer in case this body was not meant for us.
var memoryStream = new MemoryStream();
await Request.Body.CopyToAsync(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
Request.Body = memoryStream;
}
var form = await Request.ReadFormAsync();
Request.Body.Seek(0, SeekOrigin.Begin);
openIdConnectMessage = new OpenIdConnectMessage(form);
}
if (openIdConnectMessage == null)
{
return null;
}
ExceptionDispatchInfo authFailedEx = null;
try
{
var messageReceivedNotification = new MessageReceivedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions>(this.Context, this.Options)
{
ProtocolMessage = openIdConnectMessage
};
await this.Options.Notifications.MessageReceived(messageReceivedNotification);
if (messageReceivedNotification.HandledResponse)
{
return null;
}
if (messageReceivedNotification.Skipped)
{
return null;
}
// runtime always adds state, if we don't find it OR we failed to 'unprotect' it this is not a message we should process.
AuthenticationProperties properties = null;
if (properties == null)
{
return null;
}
}
catch (Exception exception)
{
// We can't await inside a catch block, capture and handle outside.
authFailedEx = ExceptionDispatchInfo.Capture(exception);
}
if (authFailedEx != null)
{
//Refresh the configuration for exceptions that may be caused by key rollovers.The user can also request a refresh in the notification.
if (this.Options.RefreshOnIssuerKeyNotFound && authFailedEx.SourceException.GetType() == typeof(SecurityTokenSignatureKeyNotFoundException))
{
this.Options.ConfigurationManager.RequestRefresh();
}
var authenticationFailedNotification = new AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions>(this.Context, this.Options)
{
ProtocolMessage = openIdConnectMessage,
Exception = authFailedEx.SourceException
};
await this.Options.Notifications.AuthenticationFailed(authenticationFailedNotification);
if (authenticationFailedNotification.HandledResponse)
{
return null;
}
if (authenticationFailedNotification.Skipped)
{
return null;
}
authFailedEx.Throw();
}
return null;
}
}
上面的代码是发生此错误所需的最少代码量,只要该代码使用了来自options的任何内容。通知应用程序立即崩溃,但找不到方法异常。
Notification属性的设置如下:
Notifications = new OpenIdConnectAuthenticationNotifications
{
RedirectToIdentityProvider = context =>
{
if (Startup.IsApiRequest(context.Request))
{
context.HandleResponse();
return Task.FromResult(0);
}
context.ProtocolMessage.RedirectUri = redirectUri;
context.ProtocolMessage.PostLogoutRedirectUri = postLogoutRedirectUri;
return Task.FromResult(0);
},
AuthenticationFailed = context =>
{
context.OwinContext.Response.Redirect("/Home/Error");
context.HandleResponse(); // Suppress the exception
return Task.FromResult(0);
},
AuthorizationCodeReceived = context =>
{
var userIdentity = context.AuthenticationTicket.Identity;
userIdentity = userIdentity.TransformClaims();
context.AuthenticationTicket = new AuthenticationTicket(
userIdentity,
context.AuthenticationTicket.Properties
);
return Task.FromResult(0);
},
SecurityTokenReceived = context => Task.FromResult(0),
}
});
小家伙,我不是这段代码的原始开发者。...
答案 0 :(得分:1)
尝试替换
Predicate<String> predicate = p -> p.length() == 21;
Stream<Boolean> stream = stringList().stream().map(predicate);
与
using Microsoft.IdentityModel.Protocols;
代码中的任何地方。那应该可以解决问题。