简体   繁体   English

获取Windows用户名,而不是以ASP .NET Web窗体4.5登录用户名

[英]getting windows username instead of logged in user name in asp .net web form 4.5

Web Config: 网络配置:

<authentication mode="Forms">
  <forms loginUrl="/Public/Login.aspx" protection="All" timeout="30" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>
</authentication>

Loggin Code: 登录码:

if (userLoginResults.UserLoginStatus == UserLoginStatus.Successful)
        {
            var email = UserName.Text.ToLower().Trim();

            if (userLoginResults.Contains(UserRoleNames.Admin))
            {
                FormsAuthentication.RedirectFromLoginPage(email, RememberMe.Checked);
                Session["isMemberLoggedIn"] = true;
                Response.Redirect("~/AdminPanel/Default.aspx");
            }

} }

// var email = User.Identity.Name; // var email = User.Identity.Name;

I did login by admin@admin.com but i am getting DESKTOP-OPT261T\\mobasshir. 我确实通过admin@admin.com登录,但是我正在获取DESKTOP-OPT261T \\ mobasshir。 this is my windows username.. How can i solve this? 这是我的Windows用户名。我该如何解决?

I am using windows 10. microsoft visual studio professional 2013 我正在使用Windows 10. Microsoft Visual Studio Professional 2013

Thanks all 谢谢大家

在此处输入图片说明 I have fixed it by disable the windows authentication... i did it by clicking on webproject from visual studio and then pressed f4 then windows authentication to disbled 我已经通过禁用Windows身份验证来修复它...我是通过从Visual Studio中单击webproject来完成的,然后按f4键,然后Windows身份验证消失

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用asp.net Web应用程序获取用户登录窗口的名称 - get name of User logged into windows using asp.net web application 获取Windows登录用户名ASP .net - Get Windows logged-in Username ASP .net 我无法访问已登录用户的用户名。 (ASP.NET Core Web API) - I can't access the UserName of the logged in user. (ASP.NET Core Web API) .NET 4.0-&gt; 4.5 Context.User.Identity.Name在窗体身份验证后不再设置(总是返回Windows用户名) - .NET 4.0 -> 4.5 Context.User.Identity.Name is no longer set after Forms Authenication (always returns Windows username) 在ASP.NET Web窗体中使用.NET 4.5 HttpClient - using .NET 4.5 HttpClient in ASP.NET Web form 在ASP.NET中获取已登录用户的userID - Getting the userID of a logged in User in ASP.NET Asp net Core 获取用户 Windows 用户名 - Asp net Core Get user Windows username 将用户添加到asp.net mvc 4.5中的角色时,出现错误-“未找到用户(用户名)” - When adding a user to a role in asp.net mvc 4.5, i'm getting an error- “user (user name) not found” 在 ASP .NET Core 6.0 中获取 Windows 用户名 - Getting the Windows User Name in ASP .NET Core 6.0 如果未使用 C# 登录 ASP.NET Web 表单,则将用户重定向到登录 - Redirect user to login if not logged in ASP.NET web form using C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM