Sitecore的使用玻璃映射器和MVC [英] Sitecore using Glass mapper and MVC

查看:350
本文介绍了Sitecore的使用玻璃映射器和MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜正在使用与Sitecore的MVC结合玻璃映射器。我创建了下面的模型。

Hi am using the Glass mapper in combination with Sitecore MVC. I created model below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Test
{
    using Glass.Mapper.Sc.Configuration.Attributes;

        [SitecoreType(AutoMap = true)]
        public class GlassTestModel
        {           
            public virtual string Title { get; set; }
        }
    }

这是我的看法。

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Test.GlassTestModel>
<div>
<h2>Hello</h2>
<h2>@Model.Title</h2>
</div>

我也试过这个第一行

I also tried this first line

@model Test.GlassTestModel

和这个

@inherits System.Web.Mvc.WebViewPage<Test.GlassTestModel>

我创建了Sitecore的渲染视图。配置上面使用的模型。
当我渲染视图模型领域没有得到填充。当我在一个控制器测试我使用其他控制器的看法如下图所示:

I created a view rendering in Sitecore. configured the model to use above. When I render the view the model fields don't get filled. When I test in a controller I use for other controller view like below:

ISitecoreContext ctx = new SitecoreContext();
var item = ctx.GetCurrentItem<Test.GlassTestModel>();

我拿到冠军现场。任何想法?

I do get the title field. Any ideas?

推荐答案

我迁移我的解决Glass.Mapper包V4。这工作。随着V3我不能得到自动映射工作。

I migrated my solution to V4 of the Glass.Mapper package. This works. With V3 I can't get the automapping to work.

这篇关于Sitecore的使用玻璃映射器和MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆