2011-11-07 32 views
0

我公司的一些開發人員在開發內部系統時遇到問題。在下面的代碼片段中,應爲winID分配當前系統的用戶ID。相反,它被分配給別人的ID,顯然是隨機的。有什麼建議麼?爲什麼會得到隨機的用戶ID而不是當前用戶?

public partial class _Default : System.Web.UI.Page 
{ 
    protected void Page_PreInit(object sender, EventArgs e) 
    { 
     Page.Theme = "MasterTheme1"; 
     if (Session["UserName"] == null) 
     { 
      using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate()) 
      { 
       WindowsIdentity winID = System.Security.Principal.WindowsIdentity.GetCurrent(); 
       Session["UserName"] = winID.Name; 
      } 
     } 
     Response.Redirect("MainDB_Login.aspx"); 
    } 
    protected void Page_Load(object sender, EventArgs e) 
    //Snip 
} 

回答

0

可能緩存在適當位置(瀏覽器或服務器上)?

相關問題