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).
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=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
used by 'EPiServer.Shell' matches identity 'System.Web.Mvc, Version=22.214.171.124, 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 126.96.36.199
The version I use for EPiServer.Shell is 188.8.131.52
Does it mean I have to downgrade my System.Web.MVC? That is not very logical
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):
<system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=184.108.40.206, 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=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> </compilers> </system.codedom>
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.
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.
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?
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).
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;
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?