System.Web.HttpContext.Current.User.Identity.Name
返回「null」。HttpContext.Current.User.Identity.Name返回null
我絕對登錄了。
這怎麼解決?
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
if (Session["FirstName"] == null)
{
string loginName = System.Web.HttpContext.Current.User.Identity.Name;
string networkId = loginName.Split('\\')[1];
Session["FirstName"] = new AD_Utility().FirstName(networkId);
}
ViewBag.FirstName = Session["FirstName"];
}
試着看看這個其他問題[HttpContext.Current.User.Identity.Name總是string.Empty](http://stackoverflow.com/questions/1056487/httpcontext-current-user-identity-name- is-always-string-empty) –