2010-01-12 65 views
1

在將大量DotNetOpenAuth項目附加到我的網站後,我收到了很多未處理的異常,如下所示。你能幫我解決這個問題嗎?HTTP動詞頭是無法識別和不支持的

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) 


--------------- 

回答

2

您發現了一個錯誤。謝謝。我有filed it

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); 
     } 
    } 
} 

在此期間,您可以通過修改RelyingPartyLogic OAuthAuthenticationModule.cs文件的context_AuthenticateRequest方法是此變通辦法,