【问题标题】:'HttpContext' does not contain a definition for 'GetOwinContext' in c# .net framwork 4.5'HttpContext' 不包含 c# .net 框架 4.5 中的'GetOwinContext' 的定义
【发布时间】:2022-03-21 08:08:12
【问题描述】:

您好,我正在尝试添加 OpenID 连接并在应用程序中运行此代码

 protected void btnLoginopenID_Click(object sender, EventArgs e)
    {

        try
        {

            if (!Request.IsAuthenticated)
            {
                //Response.Redirect("~/AccessDenied2.aspx", false);
                HttpContext.Current.GetOwinContext().Authentication.Challenge();
            }


        }
        catch (Exception exception)
        {
        }
    }

我在尝试运行代码时收到此错误消息

CS1061“HttpContext”不包含“GetOwinContext”的定义,并且找不到接受“HttpContext”类型的第一个参数的扩展方法“GetOwinContext”

enter image description here

我试过了

Install-Package Microsoft.Owin.Host.SystemWeb

但对我没有任何解决问题的建议,或者如果您知道任何将 OpenID Connect 集成到 C# .net framework 4.5 for WebForm.aspx 的方法,请告诉我

【问题讨论】:

  • 这能回答你的问题吗? Can't find Request.GetOwinContext
  • 其他人通过安装 Microsoft.AspNet.WebApi.Owin 并使用命名空间 System.Net.Http 解决了这个问题
  • 我使用过但没有解决问题。我从早上开始就在尝试这个
  • 你也需要正确的using,因为这是一种扩展方法

标签: c# .net openid-connect


【解决方案1】:

缺少 Microsoft.Owin.Host.SystemWeb 包

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2014-11-29
  • 1970-01-01
  • 2015-10-31
  • 2018-08-07
  • 2019-09-22
  • 1970-01-01
  • 2019-09-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多