【发布时间】:2009-09-03 07:54:53
【问题描述】:
SharePoint 的搜索框有问题。每当我们尝试搜索我们得到的东西时:
无法验证数据。在 System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(布尔 fEncrypt, Byte[] buf, Byte[] 修饰符, Int32 开始,Int32 长度,IVType ivType, Boolean useValidationSymAlgo) 在 System.Web.UI.ObjectStateFormatter.Deserialize(字符串 inputString) 异常。
有没有人知道这个异常的原因,或者解决它的方法?
新条目:
我正在使用 SPGridView,我在 Web 部件中使用 datakeys 属性。 webpart 可以工作,但我们发现使用 datakeys 属性会破坏 seach,如果您尝试使用搜索文本框并单击 seach 按钮,则会出现此异常:
无法验证数据。在 System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(布尔 fEncrypt,Byte[] buf,Byte[] 修饰符,Int32 开始,Int32 长度,IVType ivType,布尔 useValidationSymAlgo) 在 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
这是我尝试做的:
使 gridview 不是 spgridview 并设置 autogenerate true(有效) 删除数据键名(作品) 使用空的 gridvew 进行测试(失败) 使用非空网格视图进行测试(失败) 更改机器密钥(失败) 在 gridvew 上切换视图状态(失败) 将 gridview 移至 ascx 文件(失败)
我似乎无法弄清楚这一点。有没有人遇到此错误并能够解决它?
编辑 10.09.2009
这是我测试的最后一个代码。我使用了一个 MSDN 示例作为参考。我也试过没有数据表MSDN Example
public class TestErrorGridView : System.Web.UI.WebControls.WebParts.WebPart
{
Control ascxToAdd;
protected DataTable PropertyCollection = new DataTable();
private DataColumn key;
public TestErrorGridView()
{
key = PropertyCollection.Columns.Add("ID", typeof(string));
PropertyCollection.Columns.Add("Name", typeof(string));
}
public void AddProperty(TestBindObject data)
{
DataRow newRow = PropertyCollection.Rows.Add();
newRow["ID "] = data.ID;
newRow["Name"] = data.Name;
}
public void BindGrid(SPGridView grid)
{
SPBoundField fldPropertyName = new SPBoundField();
fldPropertyName.HeaderText = "ID";
fldPropertyName.DataField = "ID";
grid.Columns.Add(fldPropertyName);
SPBoundField fldPropertyValue = new SPBoundField();
fldPropertyValue.HeaderText = "Name";
fldPropertyValue.DataField = "Name";
grid.Columns.Add(fldPropertyValue);
PropertyCollection.PrimaryKey = new DataColumn[] { key };
grid.DataSource = PropertyCollection.DefaultView;
grid.DataKeyNames = new string[] { key.ColumnName };
grid.DataBind();
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
TestBindObject t1 = new TestBindObject() { ID = 1, Name = "Test3" };
this.AddProperty(t1);
SPGridView testGrid = new SPGridView() { AutoGenerateColumns = false };
this.BindGrid(testGrid);
this.Controls.Add(testGrid);
}
}
[Serializable]
public class TestBindObject
{
public int ID { get; set; }
public string Name { get; set; }
}
【问题讨论】:
-
我不认识 Alex,这可能只是 web.config 相关的......我同意 Kane 的观点,他应该检查所有 web.configs 中的机器密钥
-
你能发一些网格代码吗?
标签: sharepoint wss-3.0