我正在尝试将图像项添加到内容树 - 但我在以下点获得了访问被拒绝错误:
item.Add("New Node1"......
我的方法的完整代码是:
Sitecore.Data.Database master;
master = Sitecore.Configuration.Factory.GetDatabase("master");
Item item = master.Items["/sitecore/Content/Media/Images/Places"];
// item.Fields["Related Issues"].Value = "Asia and the Pacific";
if (item != null)
{
// add a new Item based on the Document Template
Item itm = item.Add("New Node1", master.Templates[new ID(new Guid("EJ0F53DF-5486-4UF4-A2D1-64C119E419A5"))]);
if (itm != null)
{
// report the Item path to the User
Response.Write(itm.Paths.Path);
}
}
Run Code Online (Sandbox Code Playgroud)
Mic*_*rds 10
运行用户Sitecore的上下文可能没有对内容树的这一部分的权限.使用Access Viewer工具进行检查.如果是这种情况,则将方法包装在Security Disabler中,如下所示:
using (new Sitecore.SecurityModel.SecurityDisabler())
{
// enter your code here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2576 次 |
| 最近记录: |