using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Data.SqlClient; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page ... { protected void Page_Load(object sender, EventArgs e) ...{ } private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password) ...{ bool boolReturnValue = false; // Insert code that implements a site-specific custom // authentication method here. // This example implementation always returns false. string strConnection = "server=.;database=liuwei;uid=sa;pwd=;"; SqlConnection Connection = new SqlConnection(strConnection); String strSQL = "Select * From liuwei"; SqlCommand command = new SqlCommand(strSQL, Connection); SqlDataReader Dr; Connection.Open(); Dr = command.ExecuteReader(); while (Dr.Read()) ...{ if ((UserName == Dr["name"].ToString()) & (Password == Dr["Password"].ToString())) ...{ boolReturnValue = true; } Dr.Close(); return boolReturnValue; } } protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) ...{ bool Authenticated = false; Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password); e.Authenticated = Authenticated; if (Authenticated == true) ...{ Response.Redirect("Default2.aspx"); } } } 当我运行的时候 就报出错误 “_Default.SiteLevelCustomAuthenticationMethod(string, string)”: 并非所有的代码路径都返回值 请教一下是怎么搞的~!