为什么我的 httpcontext 正在检索我的身份验证用户而不是登录表单用户?

Why my httpcontext is retrieving my authentication user instead of login form user?

我不知道我的 httpcontex.current.intentity.name 是如何在什么时候被 windows 身份验证用户替换的。

运行 我的 MVC 应用程序本地主机正在使用我的登录表单用户。但是在 IIS 中正在使用我的 Windows 身份验证用户。

我在 IIS 中启用了 windows 身份验证。

为什么?

"But in IIS is taking my Windows Authentication user.

I have enable windows authentication in IIS."

听起来您确实已经回答了自己的问题,但为了清楚起见:- 如果您使用的是表单身份验证,那么您不需要 Windows 身份验证。如果您在 IIS 中启用此功能,Windows 用户的用户身份将从 IIS 传递到您的应用程序。

我认为如果您在 IIS 中关闭 Windows 身份验证并改为启用匿名身份验证,那么您的应用程序将等待用户通过您的登录表单登录,然后再尝试识别他们。