运行此代码时结果不显示 [英] Result Not Showing When I Run This Code

查看:69
本文介绍了运行此代码时结果不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此代码获取Windows的用户名时,它在localhost中运行正常但是当我运行ip时运行时出现错误但用户名未显示

when i run this code to get user name of windows it run OK in localhost but when i run with ip it running with out error but the user name not showing

System.Security.Principal.IPrincipal user;
            user = System.Web.HttpContext.Current.User;
            System.Security.Principal.IIdentity identity;
            identity = user.Identity;
            TextBox1.Text = identity.Name.Substring(identity.Name.IndexOf(@"\") + 1);

推荐答案

您好,朋友,请选中集成Windows身份验证选项并取消选中身份验证方法窗口IIS中的启用匿名访问选项。
Hello friend, please check Integrated Windows authentication option and uncheck Enable anonymous access option in Authentication Methods window IIS.


这篇关于运行此代码时结果不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆