1

I followed the Glass tutorial (http://glass.lu/docs/tutorial/sitecore/tutorial14/tutorial14.html) to get Page Editor working with Glass and Sitecore MVC.

I have a basic View Rendering which shows up fine when I have basic HTML and Sitecore Helper Methods in it.

<div>
    @Html.Sitecore().Field("Title")
</div>

The moment I go to convert this to a GlassView, I get the following exception:-

The view at '/Views/Layouts/SampleContent.cshtml' must derive from WebViewPage, or WebViewPage.

Here is my View:-

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<TestMVCContent.Sample_Item>

<div>
    @Editable(x => x.Title)
</div>

I am running Sitecore 7.1 - Update-1, and have installed both the Glass.Mapper.Sc.Mvc-4 and Glass.Mapper.Sc.CastleWindsor Nuget packages.

Here is part of the web.config inside my Views folder.

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />        
        <add namespace="System.Web.Routing" />
        <add namespace="Sitecore.Mvc" />
        <add namespace="Sitecore.Mvc.Presentation" />        
      </namespaces>
    </pages>
  </system.web.webPages.razor>

I can see GlassView inherits from WebViewPage....so I don't know why it's not working. Is there something I need to register in my Views to get this working?

Thanks.

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
Sean Holmesby
  • 2,135
  • 3
  • 23
  • 34

1 Answers1

2

The release version 3.2.0.35 of the Glass.Mapper.Sc.Mvc DLLs were build against older versions of the System.Web.Mvc and System.Web.WebPages DLLs.

This has been fixed in the latest release of the DLLs, 3.2.0.41.

For older versions, this can be fixed by adding some assembly binding redirects:

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
Sean Holmesby
  • 2,135
  • 3
  • 23
  • 34
Michael Edwards
  • 6,308
  • 6
  • 44
  • 75