将伟大的DotNetOpenAuth项目附加到我的网站后,我有很多未处理的异常,如下所示。你能帮帮我吗?
Event message: An unhandled exception has occurred.
Event time: 1/9/2010 5:59:04 AM
Event time (UTC): 1/9/2010 11:59:04 AM
Event ID: fa8b51280ff94c52b24658def6e0a530
Event sequence: 9
Event occurrence: 1
Event detail code: 0
Process information:
Process ID: 3568
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: System.ArgumentException
Exception message: The HTTP verb 'HEAD' is unrecognized and unsupported.
Parameter name: httpVerb
Request information:
Request URL: http://www.amiproject.com/
Request path: /
User host address: xxx.xxx.xxx.xxx
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 8
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at DotNetOpenAuth.Messaging.ErrorUtilities.ThrowArgumentNamed(String parameterName, String message, Object[] args) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\Messaging\ErrorUtilities.cs:line 321
at DotNetOpenAuth.Messaging.MessagingUtilities.GetHttpDeliveryMethod(String httpVerb) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\Messaging\MessagingUtilities.cs:line 663
at DotNetOpenAuth.Messaging.MessagingUtilities.GetRecipient(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\Messaging\MessagingUtilities.cs:line 647
at DotNetOpenAuth.OAuth.ChannelElements.OAuthChannel.ReadFromRequestCore(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ChannelElements\OAuthChannel.cs:line 150
at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\Messaging\Channel.cs:line 372
at DotNetOpenAuth.OAuth.ServiceProvider.ReadRequest(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ServiceProvider.cs:line 222
at RelyingPartyLogic.OAuthAuthenticationModule.context_AuthenticateRequest(Object sender, EventArgs e) in C:\My Data\Project\AmiProject Source\RelyingPartyLogic\OAuthAuthenticationModule.cs:line 60
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
---------------
答案 0 :(得分:2)
你发现了一个错误。谢谢。我filed it。
与此同时,您可以通过修改RelyingPartyLogic OAuthAuthenticationModule.cs文件的context_AuthenticateRequest
方法来解决此问题:
private void context_AuthenticateRequest(object sender, EventArgs e) {
// Don't read OAuth messages directed at the OAuth controller or else we'll fail nonce checks.
if (this.IsOAuthControllerRequest()) {
return;
}
if (HttpContext.Current.Request.HttpMethod != "HEAD") { // workaround: avoid involving OAuth for HEAD requests.
IDirectedProtocolMessage incomingMessage = OAuthServiceProvider.ServiceProvider.ReadRequest(new HttpRequestInfo(this.application.Context.Request));
var authorization = incomingMessage as AccessProtectedResourceRequest;
if (authorization != null) {
this.application.Context.User = OAuthServiceProvider.ServiceProvider.CreatePrincipal(authorization);
}
}
}