法验证数据。

skyexpress 2005-03-18 08:13:27

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Web.HttpException: 无法验证数据。

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:


[HttpException (0x80004005): 无法验证数据。]
System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +196
System.Web.UI.LosFormatter.Deserialize(String input) +60

[HttpException (0x80004005): Authentication of viewstate failed. 1) If this is a cluster, edit <machineKey> configuration so all servers use the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. 2) Viewstate can only be posted back to the same page. 3) The viewstate for this page might be corrupted.]
System.Web.UI.LosFormatter.Deserialize(String input) +118
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +102

[HttpException (0x80004005): Invalid_Viewstate
Client IP: 61.147.168.94
Port: 3595
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
ViewState: dDwyMTM2MzgzMjg3O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDM+O2k8NT47aTw5PjtpPDE1PjtpPDE2PjtpPDI0PjtpPDI2Pjs+O2w8dDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs7Pjt0PHA8bDxWaXNpYmxlOz47bDxvPGY+Oz4+Ozs++O2w8MTMzMjU4NzI4ODE7Pj47Pjs7Pjs+Pjt0PDtsPGk8MD47PjtsPHQ8cDxwPGw8VGV4dDs+O2w8MTMzMjU4NzI4ODE7Pj47Pjs7Pjs+Pjt0PHA8cDxsPFRleHQ7PjtsPOW8gOmAmjs+Pjs+Ozs+O3Q8O2w8aTwwPjs+O2w8dDxwPHA8bDxUZXh0Oz47bDzlvIDpgJo7Pj47Pjs7Pjs+Pjs+Pjs+Pjs+Pjs+Pjs+Pjs+wgGPnF53vBwbJOihp0ghuhO+V5I=
Http-Referer: http://skyexpress.611.cn/list.aspx
Path: /list.aspx.]
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +448
System.Web.UI.Page.LoadPageViewState() +18
System.Web.UI.Page.ProcessRequestMain() +447


...全文
144 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyexpress 2005-03-19
  • 打赏
  • 举报
回复
网址:http://skyexpress.611.cn/list.aspx

快速点击时更易错!!
skyexpress 2005-03-19
  • 打赏
  • 举报
回复
在本机上通过,在internet上错
minghui000 2005-03-19
  • 打赏
  • 举报
回复
up
skyexpress 2005-03-19
  • 打赏
  • 举报
回复
我的代码
void setchild()
{
DataView Objview=(DataView)Cache["view"];
Hashtable selecttable=new Hashtable();
selecttable.Add(viewcols[0],"");
for(int i=0 ;i<cols.Length;i++)
{
selecttable.Add(viewcols[i+1],cols[i]);
}
viewtitle.DataSource=selecttable;
viewtitle.DataTextField="key";
viewtitle.DataValueField="value";
viewtitle.DataBind();
datamsg.Text="目前共有"+listset.PageCount.ToString()+"页 ."+"共"+Objview.Count.ToString()+"家公司.";

}

void dosear(Object sender,System.EventArgs e)
{
DataView Objview=(DataView)Cache["view"];
charop checkvalue=new charop();
msg.Text="";
if(listset.PageCount>listset.CurrentPageIndex&&listset.CurrentPageIndex>=0)
{
if((viewtitlevalue.Value.Length>0)&&(viewtitle.Value!=""))
{
if((Objview.Table.Columns[viewtitle.Value]).DataType==System.Type.GetType("System.String"))
//if((Objview.Table.Columns[viewtitle.Value]).DataType==System.Type.GetType.String)
{
//Response.Write(checkvalue.getstr_u(viewtitlevalue.Value)+"hello here: "+checkvalue.error);
try
{
Cache["filter"]=viewtitle.Value+" like '%"+checkvalue.getstr_u(viewtitlevalue.Value)+"%'";

}
catch(Exception Objerror)
{
msg.Text="<font color='red'>"+Objerror.Message+"</font>";
return;
}
//Cache["filter"]=viewtitle.Value+" like '%%%'";

}
else if(checkvalue.checkint(viewtitlevalue.Value)&&(Objview.Table.Columns[viewtitle.Value]).DataType==System.Type.GetType("System.Int32"))
{
int uidint=0;
try
{
uidint=Int32.Parse(viewtitlevalue.Value);
Cache["filter"]=viewtitle.Value+" = "+uidint;
}
catch(Exception Objerror)
{
msg.Text="<font color='red'>"+Objerror.Message+"</font>";
return;
}


}else
msg.Text="<font color='red'>请输入正确的搜索字符!!</font>";
//Response.Write((Objview.Table.Columns[viewtitle.Value]).DataType+"<br>"+System.Type.GetType("System.String"));

//listset.DataSource=Objview;
//listset.DataBind();
}
else
{
Cache["filter"]="";
Cache["sort"]="";

}
//Cache["view"]=Objview;/**/
bind();
}


}
public void doviewpage(object sender,System.EventArgs e)
{
//DataView Objview=(DataView)Cache["veiw"];

charop checkvalue=new charop();

msg.Text="";
if(checkvalue.checkint(pageindexvalue.Value)&&pageindexvalue.Value.Length>0)
{
int pageindex=0;
pageindex=Int32.Parse(pageindexvalue.Value);

if(pageindex<=listset.PageCount&&pageindex>=1)
listset.CurrentPageIndex=pageindex-1;
else
pageindexvalue.Value=listset.PageCount.ToString();

bind();
listset.CurrentPageIndex=0;//不然的话会引起页号错.
}
else if(pageindexvalue.Value.Length==0||pageindexvalue.Value=="")
{
pageindexvalue.Value="0";
listset.CurrentPageIndex=0;
bind();
}

else
msg.Text="<font color='red'>请输入正确的页号!!</font>";


}
}
}
skyexpress 2005-03-19
  • 打赏
  • 举报
回复
我的代码
void Page_Init(object sender,System.EventArgs e)
{
dboper oper=new dboper(dbdir);
oper.getdatagrid(listset,viewcols,cols);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.upmsg.ServerClick += new System.EventHandler(this.doupdata);
this.clsup.ServerClick += new System.EventHandler(this.rejectedit);
this.searbutt.ServerClick += new System.EventHandler(this.dosear);
this.clsbutt.ServerClick += new System.EventHandler(this.doviewall);
this.viewresprts.ServerClick += new System.EventHandler(this.showmodimsg);
this.sortbutt.ServerClick += new System.EventHandler(this.dosort);
this.listset.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.docommand);
this.listset.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.changepage);
this.Load += new System.EventHandler(this.Page_Load);
this.Init += new System.EventHandler(this.Page_Init);

}
#endregion
void geterrors(DataSet Objset)
{

string strcnn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") +dbdir ;
dboper oper=new dboper(strcnn);
string errros=oper.geterrors(Objset,cols,tablename);
if(errros!="")
{
string js="<script language='javascript'>\r<!--\rfunction openwin()\r{";
js+="newdoc=window.open('','Upadate','width=500,height=300,resizable=\"yes\"');\rnewdoc.document.open();\rnewdoc.document.write(\""+errros+"\");\r";
js+="newdoc.document.close();\rnewdoc.document.focus();\r}\rsetTimeout('openwin()',200);\r--></script>";

Page.RegisterStartupScript("beg",js);


}

// Response.Write("newdoc.Write("+oper.geterrors(Objset,cols,tablename)+");");

}
void doupdata(object sender,System.EventArgs e)
{

string strcnn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") +dbdir ;
dboper oper=new dboper(strcnn);
DataSet Objset=new DataSet();
DataView Objview=(DataView)Cache["view"];
Objset=oper.updatedb(Objview,tablename,cols);
geterrors(Objset);
modimsg.Text="<font color='red'>注意:请仔细查看你的修改信息!!</font>";
upmsg.Visible=false;
clsup.Visible=false;

//Response.Write(oper.error);



}
void rejectedit(object sender,System.EventArgs e)
{
DataView Objview=(DataView)Cache["view"];
Objview.Table.RejectChanges();
if(Objview.Count==0)
listset.CurrentPageIndex=0;
Cache["view"]=Objview;

bind();
modimsg.Text="<font color='red'>注意:请仔细查看你的修改信息!!</font>";
upmsg.Visible=false;
clsup.Visible=false;

}
void setsortkey()
{
Hashtable h=new Hashtable();
for(int i=0;i<cols.Length;i++)
{
h[viewcols[i+1]]=cols[i];
}
sortkey.RepeatDirection=RepeatDirection.Horizontal;
sortkey.DataSource=h;
sortkey.DataTextField="key";
sortkey.DataValueField="value";
sortkey.DataBind();
}
void dosort(object sender,EventArgs e)
{
string sortstr="";
if(sortkey.SelectedItem!=null)
sortstr=sortkey.SelectedItem.Value;
Cache["sort"]=sortstr;
ViewState["sortexpress"]=sortstr;
if(sortstr!="")
bind();
else
msg.Text="<font color='red'>请选择排序字段!!!</font>";


}
void showmodimsg(object sender,System.EventArgs e)
{
DataView Objview=(DataView)Cache["view"];
dboper oper=new dboper(dbdir);
string msg=oper.geteditreports(Objview,viewcols,cols);
if(oper.msg!="no")
{
modimsg.Text=msg;
upmsg.Visible=true;
clsup.Visible=true;
}
else
modimsg.Text="<font color='red'>"+msg+"</font>";

}
void doviewall(object sender,System.EventArgs e)
{
Cache["filter"]="";
Cache["sort"]="";
bind();
}
private void changepage(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{

listset.CurrentPageIndex=e.NewPageIndex;
ViewState["currentpageindex"]=e.NewPageIndex;
bind();
}

private void docommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataView Objview=(DataView)Cache["view"];
Objview.Sort="id";
Label myl=new Label();
myl=(Label)e.Item.Controls[0].Controls[0].FindControl("id_id");

//LiteralControl myl=new LiteralControl();
//myl=(LiteralControl)e.Item.Controls[0].Controls[0].FindControl("gsname_id");
if(e.CommandName=="Delete")
{

int i=0;
// Label Objid=new Label();
// Objid=(Label)e.Item.Controls[0].Controls[0].FindControl("label1");

i=Objview.Find(myl.Text);
if(i>=0)
Objview.Delete(i);
if(i==Objview.Count&&e.Item.ItemIndex==0&&listset.CurrentPageIndex!=0)
listset.CurrentPageIndex=Objview.Count/listset.PageSize-1;
Cache["view"]=Objview;
bind();

}
else if(e.CommandName=="Edit")
{
//TextBox tb=new TextBox();
//tb=(TextBox)e.Item.Controls[0].FindControl("id_id");
//Response.Write("1"+e.Item.Controls[0].GetType().ToString()+"2"+e.Item.Controls[0].Controls[0].GetType().ToString()+"<br>");
//Response.Write(((LiteralControl)e.Item.Controls[0].Controls[0]).ID+" "+((LiteralControl)e.Item.Controls[0].Controls[0]).Text+" "+myl.Text+myl.ID);
Response.Redirect("bianji.aspx?id="+myl.Text);

}
else
{
// Label Objid=new Label();
// Objid=(Label)e.Item.Controls[0].Controls[0].FindControl("label1");

if(e.CommandName=="Opened")
if(e.Item.Cells[3].Text=="关闭")
{
//Label Objid=new Label();
//Objid=(Label)e.Item.FindControl("uid");
Objview.Sort="id";
int i=Objview.Find(myl.Text);
if(i>=0)
{
DataRowView Objrview=Objview[i];
Objrview.BeginEdit();
Objrview["opened"]="开通";
Objrview.EndEdit();
Cache["view"]=Objview;
bind();

}
}

else
{
//Label Objid=new Label();
//Objid=(Label)e.Item.FindControl("uid");
Objview.Sort="id";
int i=Objview.Find(myl.Text);
if(i>=0)
{
DataRowView Objrview=Objview[i];
Objrview.BeginEdit();
Objrview["opened"]="关闭";
Objrview.EndEdit();
Cache["view"]=Objview;
bind();

}

}

}


}
void bind()
{
DataView Objview=(DataView)Cache["view"];
//string strFilter="";
// string strSort="";

charop checkvalue=new charop();

if(Cache["filter"]==null)
Objview.RowFilter="";
else
Objview.RowFilter=Cache["filter"].ToString();

//Response.Write(Objview.RowFilter);
if(Cache["sort"]==null)
Objview.Sort="";
else
Objview.Sort=Cache["sort"].ToString();
try
{
listset.DataSource=Objview;
int pageint=Objview.Count/listset.PageSize+1;
if(pageint<=1||pageint>listset.PageCount)
listset.CurrentPageIndex=0;
listset.DataBind();
datamsg.Text="目前共有"+listset.PageCount.ToString()+"页 ."+"共"+Objview.Count.ToString()+"家公司.";

}
catch(Exception Objerror)
{
msg.Text="<font color='red'>"+Objerror.Message+"</font>";
}


//setchild();
}
skyexpress 2005-03-19
  • 打赏
  • 举报
回复
我的代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


using System.Data.OleDb;
using mylib;
using System.Configuration;
using mycode.usercon;
namespace mycode
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid listset;

public string tablename="main";
/// <summary>
/// 搜寻条件字符。
/// </summary>
public string strwhere="";
/// <summary>
/// 要显示的列表。
/// </summary>
public string[] cols=new string[]{"id","user","gsname","opened"};
public string[] viewcols=new string[]{"请选择查询字段","用户号","用户名","公司名称","是否开通"};
/// <summary>
/// 条件列关键字。
/// </summary>
///

public string dbdir="\\db\\mydb.mdb";

public string conditionkey="gsname";

//int pageindex=0;
protected System.Web.UI.WebControls.Literal msg;
protected System.Web.UI.WebControls.Literal datamsg;
protected System.Web.UI.HtmlControls.HtmlInputText viewtitlevalue;
protected System.Web.UI.HtmlControls.HtmlSelect viewtitle;
protected System.Web.UI.HtmlControls.HtmlInputButton searbutt;
protected System.Web.UI.HtmlControls.HtmlInputButton clsbutt;
protected System.Web.UI.HtmlControls.HtmlAnchor viewpage;
protected System.Web.UI.HtmlControls.HtmlInputText pageindexvalue;
protected System.Web.UI.WebControls.Literal modimsg;
protected System.Web.UI.HtmlControls.HtmlInputButton upmsg;
protected System.Web.UI.HtmlControls.HtmlInputButton viewresprts;
protected System.Web.UI.HtmlControls.HtmlInputButton sorttitle;
protected System.Web.UI.WebControls.RadioButtonList sortkey;
protected System.Web.UI.HtmlControls.HtmlInputButton sortbutt;
protected System.Web.UI.HtmlControls.HtmlInputButton clsup;
private void Page_Load(object sender, System.EventArgs e)
{

if(ViewState["edititemindex"]!=null&&ViewState["edititemindex"].ToString().Length!=0)
listset.EditItemIndex=(int)ViewState["edititemindex"];
if(ViewState["currentpageindex"]!=null&&ViewState["currentpageindex"].ToString().Length!=0)
listset.CurrentPageIndex=(int)ViewState["currentpageindex"];

if(ViewState["sortexpress"]!=null&&ViewState["sortexpress"].ToString().Length!=0)
Cache["sort"]=ViewState["sortexpress"].ToString();


msg.Text="";

if(!Page.IsPostBack)
{
listset.CurrentPageIndex=0;
Cache["sear"]=0;
Cache["filter"]="";
Cache["sort"]="";
msg.Text="<font color='red'>请正确输入您的数据!!!</font>";
setsortkey();
getview();
upmsg.Visible=false;
clsup.Visible=false;
if((DataView)Cache["view"]!=null)
//bind();
setchild();


}
bind();

// 在此处放置用户代码以初始化页面
}

void getview()
{
string strcnn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") +dbdir ;
dboper oper=new dboper(strcnn);
//string[] cols=new string[]{"id","user","gsname","opened"};
DataSet Objset=oper.getcolrecords(tablename,strwhere,cols,conditionkey);

if(Objset!=null)
{
if(Objset.Tables[0].Rows.Count>0)
{
DataView Objview=Objset.Tables[0].DefaultView;
Cache["view"]=Objview;

}
}
else
Response.Write(oper.error);
/**/
//Response.Write(oper.error);


}
46539492 2005-03-18
  • 打赏
  • 举报
回复
贴些代码
hackate 2005-03-18
  • 打赏
  • 举报
回复
把你的错误代码帖出来嘛

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧