Try our conversational search powered by Generative AI!

Guide for creating EPiServer module in MVC


For a client I really would like to add some new module at the top of the CMS navigation bar (after user groups). With some tutorials and trail and error I managed to get the module in the navigation and also it loads a page. Still this is a view without any style or layout. 

I've read some articles and tried to add shell sources. This works as expected. Still when I try and add


I get problems in different versions with System.Web.MVC. I found an article to ignore those warnings but then at runtime I get errors like;

'HtmlHelper' does not contain a definition for 'ShellInitializationScript' 

So my questions to you;

Is it possible to develop modules in MVC? I also noticed geta had a plugin but that is gone now?

  1. Is there a up to date guide/tutorial you suggest?
  2. Is there a layout from EPiServer I can use instead of reinventing the wheel?
    1. Anyone stumble upon this mismatch in System.Web.MVC and knows how to solve it?
Feb 10, 2020 8:12


The 'ShellInitializationScript' extension is in the namespace 'EPiServer.Framework.Web.Mvc.Html' so you need to add that using clause.

Have a look at the documentation: Adding and configuring menu items. It has a sample view file that contains the minimum you will need on your view to get it working. Note there is a comment that the 'ShellInitializationScript()' call is no longer needed (though the sample uses it ;)). Anyways following that sample you will get the default shell styles loaded for your view.

There are differences in the navigation depending on what version of CMS you are targeting, the above applies to version 11.21 and higher. See the documentation for the older versions if you need to support older version(s).

Feb 10, 2020 9:20

The main problem with using that part of the documenation is that I get in my view this;

Warning CS1702 Assuming assembly reference 'System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
used by 'EPiServer.Shell' matches identity 'System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
of 'System.Web.Mvc', you may need to supply runtime policy 

And while running the code

'HtmlHelper' does not contain a definition for 'CreatePlatformNavigationMenu' and the best extension method overload 
'MenuHelper.CreatePlatformNavigationMenu(HtmlHelper)' requires a receiver of type 'HtmlHelper'

The version I use for System.Web.MVC is
The version I use for EPiServer.Shell is

Does it mean I have to downgrade my System.Web.MVC? That is not very logical
Feb 10, 2020 10:55


About the MVC 5.2.3 vs 5.2.7 Warning, note it is just a warning. To get rid of the warning, you should install if not already installed the "Roslyn" compiler, NuGet package: Microsoft.CodeDom.Providers.DotNetCompilerPlatform.

After you install that package you can add ignore for the warning in your root web.config (see the added 1702 in the /nowarn of c# compiler):

      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701;1702" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />

Adding the DotNetCompilerPlatform package also supports the C# latest language features in your view files.

Do you have the correct using clauses? The 'CreatePlatformNavigationMenu()' extension for HtmlHelper is in namespace: EPiServer.Shell.Navigation
(or maybe the warning about the HtmlHelper is just some weird side effect of the 1702 warning about the MVC versions)
I would instll the NuGet package thta I mentioned earlier, close all view files in Visual Studio, rebuild solution/project and fix any errors you might get. Then open this new module view you are working with and see does it now work correctly.

Edited, Feb 10, 2020 11:17

Thanks Antti, I think solving the view warning is fine, by ignoring this. 

Still at runtime I'm faced with;

Unhandled exception in ASP.NET System.Web.HttpCompileException (0x80004005): C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\9de5edf6\577af9e\App_Web__admin.cshtml.b24c9069.xn5rognp.0.cs(175): error CS1929: 'HtmlHelper' does not contain a definition for 'CreatePlatformNavigationMenu' and the best extension method overload 'MenuHelper.CreatePlatformNavigationMenu(HtmlHelper)' requires a receiver of type 'HtmlHelper' 

What I do think is that the ignored warning and the runtime error are part of the same problem.. a version mismatched. I've allready checked my assembly bindings and such. 

Feb 10, 2020 11:51

No the two problems does not relate, the warnings are just warnings and your problem is what Antti described, you are missing a using statement.

I also see that the error message are looking in your Temp folder so it can be that you added it but it has not updated in teh Temporarey ASP.NET files.

You can clean that folder and build again to be sure that it has the latest files.

Are you able to show us the complete code you have for that page?

Feb 11, 2020 7:13

Where is this your view file located at? If it is not in the "default" MVC views /Views/ folder does that location have the required Web.config (same that you by default have in the root of the /Views/ folder). If for example your view file is in location /some/custom-view-location/path/my-view.cshtml you need to have the web.config file "/some/custom-view-location/" if that is your custom root for the view files (and this is ASP.NET MVC stuff and not Episerver specific).

Feb 11, 2020 7:43
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.