Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.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
C# 如何使用FormsAuthentication检测经过身份验证的用户?_C#_Asp.net_.net - Fatal编程技术网

C# 如何使用FormsAuthentication检测经过身份验证的用户?

C# 如何使用FormsAuthentication检测经过身份验证的用户?,c#,asp.net,.net,C#,Asp.net,.net,如何判断用户是否使用FormsAuthentication进行了身份验证登录 <authenticaion mode="Forms"> <forms protection="All" cookieless="UseCookies"/> </authentication> 要检查用户是否已登录,可以使用HttpContext.Current.user.Identity.IsAuthenticated 验证类型可以通过HttpContext.Current

如何判断用户是否使用FormsAuthentication进行了身份验证登录

<authenticaion mode="Forms">
   <forms protection="All" cookieless="UseCookies"/>
</authentication>

要检查用户是否已登录,可以使用HttpContext.Current.user.Identity.IsAuthenticated


验证类型可以通过HttpContext.Current.User.Identity.AuthenticationType找到,以了解使用的验证类型

不确定您的意思,但在服务器端代码:


Page.User.Identity.IsAuthenticated

一种可能的方法是使用web.config中的FormsAuthenticationModule模块并创建表单身份验证cookie


您可以参考您可以使用此代码-基于FormsEntity类

链接:


到目前为止,您有什么代码。?您想查看用户是否使用表单身份验证,或者您想知道用户是否经过身份验证?请在配置文件中从此行开始粘贴代码,以便我们可以查看您的设置以及签出以下链接您的意思是…Request.loginuseridity。。。?AuthenticationType是NTLM,但既然这是一个web应用程序,怎么可能呢?当然,我在VS.NET本地运行它。它也可以是页面上的this.User.Identity。身份验证可以通过FormsAuthentication/WindowsAuthentication/Cusom进行,Windows身份验证使用NTLM如果是身份验证模式为Forms的web应用程序,为什么NTLM会发挥作用?任何web用户都不应该使用NTML,对吗?是的,您需要查看如何在IISDid中配置它您使用forms auth登录?
if (HttpContext.Current.User != null)
  {
    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
     if (HttpContext.Current.User.Identity is FormsIdentity)
     {
         .....
     }
    }
  }