Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.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 检查Web应用程序中的Azure身份验证_Asp.net_Azure_Authentication_Azure Active Directory - Fatal编程技术网

Asp.net 检查Web应用程序中的Azure身份验证

Asp.net 检查Web应用程序中的Azure身份验证,asp.net,azure,authentication,azure-active-directory,Asp.net,Azure,Authentication,Azure Active Directory,我正在尝试将Microsoft Azure Active Directory身份验证添加到现有的ASP.NET Web应用程序。我无法将此项目转换为MVC模式。现有应用程序已具有身份验证系统。我必须保留它 以下是用于调用azure身份验证服务的代码: HttpContext.Current.GetOwinContext().Authentication.Challenge( new AuthenticationProperties { RedirectUri = "/"

我正在尝试将Microsoft Azure Active Directory身份验证添加到现有的ASP.NET Web应用程序。我无法将此项目转换为MVC模式。现有应用程序已具有身份验证系统。我必须保留它

以下是用于调用azure身份验证服务的代码:

HttpContext.Current.GetOwinContext().Authentication.Challenge(
            new AuthenticationProperties { RedirectUri = "/" },
            OpenIdConnectAuthenticationDefaults.AuthenticationType);
前面的代码提示正确的Azure身份验证页面。但是如何检查用户是否成功通过身份验证?
在MVC模式中,您只需检查Request.IsAuthenticated,我如何在此处执行相同的操作?

Request.IsAuthenticated也适用于asp.net web表单应用程序。请参阅以下代码:

private void Page_Load(object sender, EventArgs e)
{
    // Check whether the current request has been
    // authenticated. If it has not, redirect the 
    // user to the Login.aspx page.
    if (!Request.IsAuthenticated)
    {
        Response.Redirect("Login.aspx");
    }
}
您也可以尝试:

  bool IsAuthenticated = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;

由于我的Aure AuthenticationRequest,IsAuthenticated始终为false。IsAuthenticated始终为false?当我连接azure时,是的,如果我连接常规表单,它当然会变为true。但我希望能够使用这两种方法进行连接。我创建了一个新的web表单应用程序,并使用openid connect启用azure ad登录,Request.IsAuthenticated运行良好,测试项目供您参考(在web.config中配置azure ad设置)谢谢,我无法使项目正常工作,因为代码目标为4.5.2您能使其目标为4.5吗?再次感谢。