Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 以编程方式将项目添加到列表_Sharepoint_List_Login - Fatal编程技术网

Sharepoint 以编程方式将项目添加到列表

Sharepoint 以编程方式将项目添加到列表,sharepoint,list,login,Sharepoint,List,Login,我正在Sharepoint网站中使用基于表单的身份验证。在“我的登录”页面上,有未经身份验证的用户要填写的自定义字段。我想添加到列表中的这些字段。我使用以下代码在列表中插入记录 protected void AddVendor(object sender, EventArgs e) { string strList = "http://comp01:5353/Lists/Vendors/"; using (SPSite site = new SPSite(strList))

我正在Sharepoint网站中使用基于表单的身份验证。在“我的登录”页面上,有未经身份验证的用户要填写的自定义字段。我想添加到列表中的这些字段。我使用以下代码在列表中插入记录

protected void AddVendor(object sender, EventArgs e)
{
    string strList = "http://comp01:5353/Lists/Vendors/";

    using (SPSite site = new SPSite(strList))
    {
        site.AllowUnsafeUpdates = true;
        using (SPWeb web = site.OpenWeb())
        {
            web.AllowUnsafeUpdates = true;
            SPUser user = web.AllUsers["demouser"];    
            SPList list = web.Lists["Vendors"];
            SPListItem Item = list.Items.Add();
            Item["First Name"] = txtVendorName.Text;
            Item["Last Name"] = txtVLastName.Text;
            Item["business"] = txtDescription.Text;
            Item["Description"] = txtDescription.Text;
            Item["Mobile No"] = txtMobileNumber.Text;
            Item["Approved"] = "No";
            Item["Created By"] = "demoadmin";
            Item["Modified By"] = "demoadmin";   
            Item.Update();
        }
    }
}

但是is给了我一个错误,说线程被中止了。我不知道到底遗漏了什么。但这是因为我正在执行添加操作,而用户未通过身份验证…?

您在哪里编写了此代码,它是否在某个事件中?登录控件提供两个事件来帮助您解决此问题

OnLoginError="OnLoginError" OnLoggedIn="OnLoggedIn"

我做了类似的功能,我想捕获站点的用户名loggin并将其记录到DB表中。关于ThreadAbort异常,当您在执行代码时使用Response.Redirect时会发生这种情况。在您的情况下,我怀疑它是否被抛出,因为您正在尝试执行上述代码,但FBA系统试图将用户重定向到default.aspx。尝试上面提到的登录控件事件,它应该会对您有所帮助。

我不知道它是否会对您有所帮助,但显示f.e.项[Modified By]的代码将不起作用,因为这是内部名称,已被\u x0020\u修改。这适用于所有包含空格的字段

这可能是你的问题之一