加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – IAuthenticationRequest.RedirectToProvider不应该返回,

发布时间:2020-12-16 06:57:18 所属栏目:asp.Net 来源:网络整理
导读:记录DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest.RedirectToProvider()方法永远不会返回: Redirects the user agent to the provider for authentication. Execution of the current page terminates after this call. 但是,它确实在最新的
记录DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest.RedirectToProvider()方法永远不会返回:

Redirects the user agent to the
provider for authentication. Execution
of the current page terminates after
this call.

但是,它确实在最新的实施(3.4.3)下返回.我正在使用以下代码:

using (var relayingParty = new OpenIdRelyingParty())
{
  var response = relayingParty.GetResponse();

  if (response == null)
  {
    // Stage 2: user submitting Identifier
    var openId = Request.Form["openId"];
    relayingParty.CreateRequest(openId).RedirectToProvider();

    throw new Exception("Never gets here");
  }

  ...
}

(达到了“永远不会到达这里”的路线).我需要从这个方法返回一个ActionResult …

>这是一个已知的错误吗?
>有没有aorkaround?我应该返回EmptyResult吗?

据我所知,这是一个错误 – 项目问题跟踪器中的I submitted it.

解决方法

由于您使用的是ASP.NET MVC,因此您应该使用以下代码:

using DotNetOpenAuth.Messaging; // required for the extension method to work

    return relyingParty.CreateRequest(openid).RedirectingResponse.AsActionResult();

显然,ASP.NET通常会因RedirectToProvider()调用而抛出异常,但并非总是如此.但上面的代码将起作用,并且更适合MVC.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读