we have a public facing SharePoint 2013 Website and wanted to implement a custom form where anonymous users can subscribe for a newsletter. We implemented a custom visual webpart which worked nice in our test environment. After transferring the solution to production unfortunately now clicking the submit button of the form causes a HTTP error 403. Any idea why?
The relevant code of our webpart:
protected void SubscribeBtn_Click(object sender, EventArgs e)
{
string name = subscriptionName.Value;
string email = subscriptionMail.Value;
using (var site = new SPSite(SPContext.Current.Web.Url, SPUserToken.SystemAccount))
{
using (var web = site.OpenWeb())
{
var subscribeList = web.Lists["Newsletter"];
web.AllowUnsafeUpdates = true;
SPListItem item = subscribeList.Items.Add();
item["Title"] = name;
item["Email"] = email;
item.Update();
web.AllowUnsafeUpdates = false;
.
.
.
}
}
}

0 commentaires:
Enregistrer un commentaire