简体   繁体   English

如何使用DotNetOpenAuth调试400 Bad Request错误?

[英]How do I debug a 400 Bad Request error with DotNetOpenAuth?

I'm using DotNetOpenAuth to connect to the LinkedIn API. 我正在使用DotNetOpenAuth连接到LinkedIn API。 I am getting a (400) Bad Request when trying to call the BeginAuthorize method in their API. 尝试在其API中调用BeginAuthorize方法时,收到一个(400) Bad Request What am I doing wrong? 我究竟做错了什么? I'm using Windows 7 and the firewall is disabled. 我正在使用Windows 7,并且防火墙已禁用。

even i have faced the same problem. 即使我也面临着同样的问题。 this one is not related to windows 7 security policy. 这与Windows 7安全策略无关。 the Date & time (local system) is not matched with your linked-in API (server). 日期和时间(本地系统)与您链接的API(服务器)不匹配。

Debug your code and gothru the inner details of the exception.. 调试您的代码,并深入了解异常的内部细节。

By Installing Network Time Protocol in your system would solve the problem 通过在系统中安装网络时间协议可以解决该问题

Thanks, Gunasekaran Sambandhan 谢谢,Gunasekaran Sambandhan

Normally Bad request error happen because of security reasons like: 通常由于安全原因会发生错误的请求错误:

  1. Firewall 火墙
  2. Query string length it 查询字符串长度吗

Try disabling the IP Security policies in Windows 7 and see if that fixes the issue. 尝试在Windows 7中禁用IP安全策略,看看是否可以解决该问题。

When you get a 400 BadRequest , there's always more information. 当您收到400 BadRequest ,总会有更多信息。 To get that information, you have to enable logging in DotNetOpenAuth . 要获取该信息, 必须启用DotNetOpenAuth中的日志记录 Here are a few things to make sure of: 请确保以下几点:

  1. Make sure your log4net is bin deployed (copied to the bin directory where your program resides. Setting ' Copy Local ' to true in Visual Studio will do this for you. 确保您的log4net已进行bin部署(复制到程序所在的bin目录中。在Visual Studio中将“ Copy Local ”设置为true将为您完成此操作。

The 'bad request' (with complete information) will show up in wherever you have logging set up for Log4net. 无论您为Log4net设置了什么日志记录,“错误的请求”(带有完整的信息)都将显示。 Here's an example of what it looks like to set up Log4Net. 这是设置Log4Net 的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM