Logon頁面代碼如下:
private void DisablePageCaching()<br /> {<br /> Response.Expires = 0;<br /> Response.Cache.SetNoStore();<br /> Response.AppendHeader("Pragma", "no-cache");<br /> }</p><p> protected void Page_Load(object sender, EventArgs e)<br /> {<br /> DisablePageCaching();<br /> if (this.Request.Cookies[GlobalParameters.COOKIE_KEY_LOGONUSERFLAG] != null && this.Request.Cookies[GlobalParameters.COOKIE_KEY_LOGONUSERFLAG].Value.ToString() == "1")<br /> {<br /> if (HttpContext.Current.User.Identity.IsAuthenticated)<br /> {<br /> Response.Cookies[GlobalParameters.COOKIE_KEY_LOGONUSERFLAG].Value = "0";<br /> Response.Redirect("~/Default.aspx", true);<br /> }<br /> }<br /> }</p><p> protected void btnLogon_Click(object sender, EventArgs e)<br /> {<br /> Response.Cookies[GlobalParameters.COOKIE_KEY_LOGONUSERFLAG].Value = "1";<br /> Session[GlobalParameters.SESSION_KEY_LOGONUSER] = null;<br /> Response.StatusCode = 401;<br /> Response.StatusDescription = "Unauthorized";<br /> Response.AddHeader("WWW-Authenticate", "Negotiate");<br /> Response.AddHeader("WWW-Authenticate", "NTLM");<br /> }
如果使用Visual Studio Development Server而不在IIS建虛擬目錄, 就會出現錯誤
Version Information: ASP.NET Development Server 9.0.0.0
而且調試時,設斷點的話,在彈出域使用者輸入框並輸入使用者和密碼後,死活都不觸發page load了, 直接就是上邊的錯誤
解決辦法只有建一個虛擬目錄了
Server Error in '/' Application.
HTTP Error 403 - Forbidden.