我正在尝试将数据发送到DotNetOpenAuth网站,如此处所述http://msdn.microsoft.com/en-us/library/debx8sh9.aspx 发件人收到(500)内部服务器错误。没有DotNetOpenAuth的空白网站的相同代码工作正常。我应该调整一下吗?
这是一个例外:
System.ArgumentNullException was unhandled by user code
Message="Value cannot be null.\r\nParameter name: key"
Source="mscorlib"
ParamName="key"
StackTrace:
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at DotNetOpenAuth.OAuth.ChannelElements.OAuthChannel.ReadFromRequestCore(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ChannelElements\OAuthChannel.cs:line 145
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
在代码的最后一行发生异常:
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));
答案 0 :(得分:1)
如果您使用Content-Type
application/x-www-form-urlencoded
发送POST请求,但POST实体包含正常key1=value1&key2=value2
格式以外的内容,则可能会对此进行解释。看起来DotNetOpenAuth无法处理声称为name = value对的POST实体,但只有一个没有前面的键的值。可以说这是DotNetOpenAuth中的一个错误,因为通常认为它只是一个空键的值。
如果你根本没有发送key = value对,我建议你删除或更改Content-Type标题,这样你就不会声称发送key = value对。如果您要发送它们,但故意发送空密钥,请在the bug gets fixed时挂起。