我无法从我的应用程序连接到Umbraco API,我收到错误,因为“ConnectionString属性尚未初始化”。我已经从Umbraco Project将cms.dll和businesslogic.dll作为参考文件添加到我的应用程序中。
代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
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 umbraco.cms.businesslogic.member;
using umbraco.cms.businesslogic.propertytype;
namespace UmbracoCreateMember
{
public partial class Register : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRegister_Click(object sender, EventArgs e)
{
if (Member.GetMemberFromEmail(txtEmail.Text) == null)
{
MemberType demoMemberType = new MemberType(1040); //id of membertype 'demo'
Member newMember = Member.MakeNew(txtName.Text, demoMemberType, new umbraco.BusinessLogic.User(0));
newMember.Email = txtEmail.Text;
newMember.Password = txtPassword.Text;
newMember.LoginName = txtUsername.Text;
newMember.getProperty("address").Value = txtAddress.Text; //set value of property with alias 'address'
newMember.getProperty("city").Value = txtCity.Text; //set value of property with alias 'city'
newMember.Save();
}else
{
//member exists
}
}
}
}
截图:
答案 0 :(得分:1)
您必须在Web.config文件中指定umbraco实例的ConnectionString