Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 在Razor视图中找不到AuthenticationManager.GetExternalLoginFoAsync()_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 在Razor视图中找不到AuthenticationManager.GetExternalLoginFoAsync()

Asp.net mvc 在Razor视图中找不到AuthenticationManager.GetExternalLoginFoAsync(),asp.net-mvc,Asp.net Mvc,我正在mvc5应用程序中使用外部登录提供程序。在我的控制器中,我可以使用下面的命令检查是否有任何外部登录信息 await AuthenticationManager.GetExternalLoginInfoAsync(); 我如何在razor视图中使用它来检查外部登录信息是否存在。 我在下面用过 if (HttpContext.Current.GetOwinContext()==null) { ............... } 这似乎有效,但 HttpConte

我正在mvc5应用程序中使用外部登录提供程序。在我的控制器中,我可以使用下面的命令检查是否有任何外部登录信息

await AuthenticationManager.GetExternalLoginInfoAsync();
我如何在razor视图中使用它来检查外部登录信息是否存在。 我在下面用过

 if (HttpContext.Current.GetOwinContext()==null)
    {
     ...............
    }
这似乎有效,但

HttpContext.Current.GetOwinContext()

即使注销后仍不为null
我需要在ExternalLogInConfirmation页面中显示/隐藏一些相关信息

我已经为此创建了一个扩展方法

namespace MyApp.ExtensionMethods
{
    public static class Extentions
        {
        public static bool IsExternalLogInfoExists(this IPrincipal principal)
        {

           return HttpContext.Current.GetOwinContext().
                  Authentication.GetExternalLoginInfo()==null?false:true;
        }
    }
}
那么在我看来,

if (!User.IsExternalLogInfoExists())
    {
     //show/hide any thing
    }
当然,您需要在上面添加名称空间。就我而言

@using MyApp.ExtensionMethods;