Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.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
Asp.net mvc 无法在glass mapper的sitecore MVC(Razoe视图)帮助下自动映射_Asp.net Mvc_Sitecore_Glass Mapper - Fatal编程技术网

Asp.net mvc 无法在glass mapper的sitecore MVC(Razoe视图)帮助下自动映射

Asp.net mvc 无法在glass mapper的sitecore MVC(Razoe视图)帮助下自动映射,asp.net-mvc,sitecore,glass-mapper,Asp.net Mvc,Sitecore,Glass Mapper,在使用控制器渲染时,我创建了一个名为Footer.cs的模型,它具有以下属性 [SitecoreType(TemplateId = "{1044CFB5-2B85-4A8D-9DCC-34764D2AF5B3}", AutoMap = true)] public class Footer { public virtual Item Item { get; set; } [SitecoreField(FieldName ="Copyright Text First",FieldT

在使用控制器渲染时,我创建了一个名为Footer.cs的模型,它具有以下属性

[SitecoreType(TemplateId = "{1044CFB5-2B85-4A8D-9DCC-34764D2AF5B3}", AutoMap = true)]
public class Footer 
{
    public virtual Item Item { get; set; }
    [SitecoreField(FieldName ="Copyright Text First",FieldType = SitecoreFieldType.SingleLineText)]
    public virtual string CopyrightTextFirst { get; set; }

    [SitecoreField(FieldName ="Copyright Text Last",FieldType = SitecoreFieldType.SingleLineText)]
    public virtual string CopyrightTextLast { get; set; }
}
在我的控制器中:

public ActionResult FooterTemplate()
{
    ISitecoreContext ctx = new SitecoreContext();
    var model = ctx.GetCurrentItem<Footer>();
    return View(model);
}

public ActionResult FooterTemplate()
{
ISitecoreContext ctx=新建SitecoreContext();
var model=ctx.GetCurrentItem();
返回视图(模型);
}
但是,总是得到空结果,请帮助我任何一个。

您可以使用:

  public ActionResult FooterTemplate()
  {
    ISitecoreContext ctx = new SitecoreContext();
    var model = ctx.GetCurrentItem<Footer>(RenderingContext.Current.Rendering.DataSource);
    return View(model);
  }

public ActionResult FooterTemplate()
{
ISitecoreContext ctx=新建SitecoreContext();
var model=ctx.GetCurrentItem(RenderingContext.Current.Rendering.DataSource);
返回视图(模型);
}

可能有多种原因。您需要显示有关如何配置sitecore的详细信息。页脚项是您当前的“页面”项还是数据源项?它是数据源项Public ActionResult FooterTemplate(){ISitecoreContext ctx=new SitecoreContext();var model=ctx.GetItem(ItemReferences.COPYRIGHT_TEXT);返回视图(模型);}