Episerver – HtmlHelper does not contain a definition for ShellInitializationScript

If you have tried extending the navigation of Episerver and implemented a custom module with its own view and got the following errors:

‘System Web WebPages Html HtmlHelper’ does not contain a definition for ‘ShellInitializationScript’ and the best extension method overload ‘EPiServer Shell Web Mvc Html ScriptExtensions ShellInitializationScript( System Web Mvc HtmlHelper)’ has some invalid arguments

Then you most likely have created a view that does not have a web.config. Always make sure that your Views folder has a web.config that tells the system where your HtmlHelpers are:

Episerver Module views web config

A sample Views web.config would be:

<?xml version="1.0"?>
<configuration>
   <configSections>
      <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
         <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
         <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      </sectionGroup>
   </configSections>
<system.web.webPages.razor>
   <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.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" />
      </namespaces>
   </pages>
</system.web.webPages.razor>
</configuration>

Note: Confirm you have the correct versions of the assemblies above such as System.Web.Mvc.

 

%d bloggers like this: