【发布时间】:2018-07-23 04:14:10
【问题描述】:
当我的代码是:
UserPrincipal up = UserPrincipal.FindByIdentity(Context, IdentityType.SamAccountName, "Username");
在 Visual Studio 和 IIS 中没问题。
但是,当我将代码更改为:
string Name = WindowsIdentity.GetCurrent().Name;
UserPrincipal up = UserPrincipal.FindByIdentity(Context, IdentityType.SamAccountName, Name);
在 Visual Studio 中没问题,但 IIS 抛出错误:
对象引用未设置为对象的实例。
发生了什么?
【问题讨论】:
-
看起来您正在访问属性或调用
NULL对象的方法。 -
NO Shyju!在 Visual Studio 中调试时,方法获取值但在 IIS 上返回 null!
标签: asp.net asp.net-mvc iis