如何判断用户是否使用FormsAuthentication进行了身份验证(登录)?如何使用FormsAuthentication检测经过身份验证的用户?
<authenticaion mode="Forms">
<forms protection="All" cookieless="UseCookies"/>
</authentication>
如何判断用户是否使用FormsAuthentication进行了身份验证(登录)?如何使用FormsAuthentication检测经过身份验证的用户?
<authenticaion mode="Forms">
<forms protection="All" cookieless="UseCookies"/>
</authentication>
要检查用户是否已登录,您可以使用HttpContext.Current.User.Identity.IsAuthenticated
。
身份验证类型可以通过HttpContext.Current.User.Identity.AuthenticationType
被发现要知道使用的身份验证类型
您的意思是... Request.LoginUserIdentity ...? AuthenticationType是NTLM,但这是如何可能的,因为这是一个Web应用程序?当然,我使用VS.NET在本地运行它。 – 4thSpace
它也可以是this.User.Identity在一个页面上。验证也可以通过在FormsAuthentication/WindowsAuthentication/Cusom和Windows身份验证使用NTLM – Ramesh
如果它与身份验证模式=“形式的”一个Web应用程序,为什么NTLM来发挥作用?任何网络用户都不应该使用NTML吗? – 4thSpace
不知道这是你的意思,但在服务器端代码:
Page.User.Identity.IsAuthenticated
一种可能的方式是使用在web.config中FormsAuthenticationModule模块和创建表单身份验证cookie。
您可以使用此代码 - 基于FormsIdentity
类
链接:http://msdn.microsoft.com/fr-fr/library/system.web.security.formsidentity.aspx
if (HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
.....
}
}
}
你有什么代码迄今。? – MethodMan
你想看看,如果用户使用表单身份验证,或者你想知道用户是否通过身份验证? – Ramesh
在你的配置文件,请粘贴代码,从该行开始<认证模式=“表单”> 所以我们可以看到你所拥有的设置以及 – MethodMan