加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – Sitecore PageEditor随机显示Glass.Mapper的错误

发布时间:2020-12-16 07:38:40 所属栏目:asp.Net 来源:网络整理
导读:当我使用Glass.Mapper在我的Sitecore站点上以页面编辑器模式打开页面时,我有时会收到错误. You cannot save a class that does not contain a property that represents the item ID. Ensure that at least one property has been marked to contain the Sit
当我使用Glass.Mapper在我的Sitecore站点上以页面编辑器模式打开页面时,我有时会收到错误.

You cannot save a class that does not contain a property that
represents the item ID. Ensure that at least one property has been
marked to contain the Sitecore ID. Type:
Castle.Proxies.IBasicPageProxy
at Glass.Mapper.Sc.Configuration.SitecoreTypeConfiguration.ResolveItem(Object
target,Database database)
at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression’1 field,Expression’1 standardOutput,T model,Object parameters,
Context context,Database database,TextWriter writer)

这出现在渲染的位置,因此它不会显示为标准ASP错误.

重新启动IIS解决了这个问题,但很快又出现了..

我使用接口进行模型定义,每个接口继承自IBaseType:

[SitecoreType]
public interface IBaseType
{
    [SitecoreId]
    Guid Id { get; set; }

    [SitecoreInfo(SitecoreInfoType.Name)]
    string Name { get; set; }

    [SitecoreItem]
    Item InnerItem { get; set; }

    [SitecoreInfo(SitecoreInfoType.Url)]
    string Url { get; set; }

    [SitecoreInfo(SitecoreInfoType.TemplateId)]
    Guid TemplateId { get; set; }

    [SitecoreInfo(SitecoreInfoType.FullPath)]
    string FullPath { get; set; }
}

我使用Sitecore 7.5 rev. 141003(.NET 4.5,MVC5),以及最新版本的Glass.Mapper相关NuGet包目前:

> Castle.Windsor 3.3.0
> Castle.Core 3.3.3
> Glass.Mapper 3.0.14.26
> Glass.Mapper.Sc 3.2.3.46
> Glass.Mapper.Sc.CastleWindsor 3.3.0.24
> Glass.Mapper.Sc.Mvc-5 3.3.0.43

问题出现在我们尝试的所有计算机上,但它们都使用Windows 8,IIS 8.5.9600.我尝试恢复到WebActivator方法,但它没有帮助.模型定义位于单独的类库项目中,该项目引用所有玻璃映射器程序集.

我很无能,在其他项目之前从未遇到过这个错误.有没有人知道是什么原因导致的,或者我如何调试它?

谢谢您的帮助!

解决方法

我已将下面的代码放在我的模型中并且它有效

[SitecoreId]
public virtual Guid Id { get; set; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读