【发布时间】:2009-12-04 06:28:35
【问题描述】:
我在本地运行 DotNetOpenAuth 示例提供程序,它似乎可以通过 Web 浏览器正确处理请求。我可以在调试器中单步执行处理程序以进行授权。
我有一个项目可以通过 Google 和其他提供者进行身份验证,但在示例提供者中失败。示例提供者根本看不到请求,依赖方抛出异常,抱怨 No OpenID endpoint found.
假设我在依赖方执行以下操作:
string providerURL = "http://localhost/openid/provider";
// Now try the openid relying party...
var openid = new OpenIdRelyingParty();
var response = openid.GetResponse();
if (response == null)
{
Identifier id;
if (Identifier.TryParse(providerURL, out id))
{
// The following line throws the exception without ever making
// a request to the server.
var req = openid.CreateRequest(providerURL);
// Would redirect here...
}
}
我注意到UntrustedWebRequestHandler 类阻止连接到主机名,例如localhost,但是根据测试用例或手动将其添加为白名单主机,似乎没有帮助。
我已经检查了主机是否可以通过以下方式访问:
// Check to make sure the provider URL is reachable.
// These requests are handled by the provider.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(providerURL);
HttpWebResponse httpRes = (HttpWebResponse)request.GetResponse();
想法?我不知道为什么它根本不提出请求。
编辑:localhost 像这样被列入白名单:
(openid.Channel.WebRequestHandler as UntrustedWebRequestHandler).WhitelistHosts.Add("localhost");
我也尝试通过将其添加到 web.config 来将其列入白名单,如下所示:
<dotNetOpenAuth>
<messaging>
<untrustedWebRequest>
<whitelistHosts>
<add name="localhost"/>
</whitelistHosts>
</untrustedWebRequest>
</messaging>
</dotNetOpenAuth>
无论使用哪种方法,在调试器中检查时,localhost 都会显示在UntrustedWebRequestHandler 的白名单主机列表中。他们的提供者仍然没有收到任何请求。
【问题讨论】:
-
您所做的手动
WebRequest.Create测试是从您的网络应用程序还是控制台应用程序调用的?
标签: .net asp.net openid dotnetopenauth