views:

116

answers:

1

After attaching of great DotNetOpenAuth project to my site, I have got a lot of unhandled exceptions like below. Could you please help me with this?

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  A: 

You found a bug. Thanks. I've filed it.

In the meantime, you can workaround it by modifying your RelyingPartyLogic OAuthAuthenticationModule.cs file's context_AuthenticateRequest method to be this:

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