| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1157 人关注过本帖
标题:System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集 ...
取消只看楼主 加入收藏
aipaw
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-6-5
收藏
 问题点数:0 回复次数:0 
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 = "";
    }
}







搜索更多相关主题的帖子: password 文件夹 源文件 
2011-06-05 07:57
快速回复:System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055172 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved