System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
源错误: 行 39: {
行 40: string password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtLoginPassword.Text.ToString(), "MD5");
行 41: if (AdminsManager.AdminLogin(this.txtLogin.Text.ToString(), password, out user))
行 42: {
行 43: string strRedirect;
源文件: g:\工作文件夹\程序调试1\Admin\Admin_Login.aspx.cs 行: 41
堆栈跟踪:
[ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index]
System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +64
System.ThrowHelper.ThrowArgumentOutOfRangeException() +15
System.Collections.Generic.List`1.get_Item(Int32 index) +7499252
ObjectDAL.AdminService.AdminLogin(String loginId) in E:\东方之星网站\20110408\ObjectDAL\AdminService.cs:208
ObjectBLL.AdminsManager.AdminLogin(String loginId, String password, Admin& ValidAdmin) in E:\东方之星网站\20110408\ObjectBLL\AdminsManager.cs:131
Admin_Admin_Login.btnLogin_Click1(Object sender, EventArgs e) in g:\工作文件夹\程序调试1\Admin\Admin_Login.aspx.cs:41
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +107
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3440
==========================================================================================================
=========================================下面是错误的文件=================================================
==========================================================================================================
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ObjectModles;
using ObjectBLL;
public partial class Admin_Admin_Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Admin user;
if (!IsPostBack)
{
if (Session["CurrentUser"] != null)
{
user = (Admin)Session["CurrentUser"];
}
}
}
protected void btnLogin_Click1(object sender, EventArgs e)
{
Admin user;
if (this.txtLogin.Text.ToString() == null || this.txtLoginPassword.Text.ToString() == " " || this.txtLogin.Text.ToString() == "")
{
Response.Write("<script>alert('用户名或密码不能为空,请重新填写')</script>");
}
else
{
string password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtLoginPassword.Text.ToString(), "MD5");
if (AdminsManager.AdminLogin(this.txtLogin.Text.ToString(), password, out user))
{
string strRedirect;
//表单验证所指定的路径
strRedirect = Request["ReturnUrl"];
//表单验证
System.Web.Security.FormsAuthentication.SetAuthCookie(user.UserName, true);
Session["CurrentUser"] = user;
if (strRedirect == null)
{
Response.Redirect("~/Admin/index.aspx");
}
Response.Redirect(strRedirect);
}
else
{
Response.Write("<script>alert('用户名或密码不正确,请重新填写')</script>");
}
}
}
protected void btnLogin0_Click(object sender, EventArgs e)
{
this.txtLogin.Text = "";
this.txtLoginPassword.Text = "";
}
}