【发布时间】:2014-06-19 15:44:17
【问题描述】:
我的应用程序正在检索错误的身份。它使用的是我的操作系统名称,而不是我的 Web 应用程序用户名。我尝试使用以下代码设置新身份,但它仍然获取我的操作系统帐户名称。
If User.Identity.Name = "DOMAIN\Name" Then
FormsAuthentication.SignOut()
HttpContext.Current.User = New GenericPrincipal(New GenericIdentity(String.Empty), Nothing)
End If
我想从User.Identity.Name 强制注销,因为每次启动时,名称都是错误的。在通过应用程序登录之前,我可以使用默认名称为 null 构建我的 Web 应用程序吗?
我已尝试重新启动我的桌面,但名称仍取自我的操作系统身份。我怎样才能让它停下来!!!
注意:用户名的设置方式是弹出一个提示我操作系统帐户的用户名和密码的弹出窗口,但网站不应该这样做。这是操作系统验证。现在我需要将其分离。
<authentication mode="Forms">
<forms loginUrl="login.aspx" defaultUrl="Welcome.aspx" cookieless="UseCookies" slidingExpiration="true" timeout="20" name=".Auth" protection="All">
</forms>
</authentication>
【问题讨论】:
-
如果它是从您的 PC\Domain 获取您的用户名.. 那么这不是表单身份验证,因此 formsauthentication.signout 可能无济于事。这可能与在 IIS 中托管应用程序有关,它可能设置为 Windows 身份验证.. 对吗?
-
@weitknows 模式设置为 web.config 上的表单,我已经更新了我的问题。
-
@GivenPie 您目前是否在本地计算机上使用 Visual Studio 调试此应用程序?
标签: asp.net asp.net-membership identity membership-provider membership