1
나는 둘러 보았지만 여전히 이에 대한 대답을 얻지 못했습니다.ASP.Net 전역 파일 내에서 사용자 ID를 얻는 중
나는 ASP.NET 응용 프로그램이 있으며 Windows 인증을 사용합니다. 의 Web.config가 제대로 구성 : WindowsAuthentication_Authenticate (개체를 보낸 사람, WindowsAuthenticationEventArgs 전자) 사용자 ID지고
코드 :
var userId = String.Empty;
//Dispalys the UserName from AD.
System.Security.Principal.IPrincipal User;
User = System.Web.HttpContext.Current.User;
if (User != null)
{
string username = User.Identity.Name;
username = username.Substring(username.IndexOf("\\") + 1);
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;
userId = (textInfo.ToTitleCase(username));
}
을
<authentication mode="Windows"/>
<authorization>
<deny users="?"/>
</authorization>
나는 방법에서 사용자 ID를 얻고있다 System.Web.HttpContext.Current.User는이 경우 항상 null입니다.
여기서 내가 뭘 잘못하고 있니?