I'm creating a custom plugin against Nop 3.9. I'm using Visual Studio Community 2017 Edition. I created a class library using .NET Framework 4.5.1 and using NuGet I added "Microsoft.AspNet.Mvc" and all other packages. Basically, I'm duplicating an existing plugin.
I copied the web.config file from another plugin and pasted it into my plugin. All the references in my plugin are there including System.Web.Mvc version 5.2.3. However, my CSHTML files are not recognizing WebViewPage variable. It's showing the red squiggly line under it. This is, however, working on existing plugins.
I have a feeling that I need to hack something to get this working because apparently using NuGet is not enough.
Please, can anyone tell me what I'm doing wrong? This has taken 4 days of my time trying to get this thing to work with no success. Please see below for details. I have cleaned my plugin, rebuilt it, cleaned the Nop solution, rebuilt it but nothing works.
Here's my web.config file at the Class Library (Plugin) level.
<?xml version="1.0" encoding="utf-8"?>
<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>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation targetFramework="4.5.1" />
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="Nop.Web.Framework.ViewEngines.Razor.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>
Here's the code giving error in my cshtml. The bold is not recognized and errors out.
@model MyListModel
@{
var defaultGridPageSize = EngineContext.Current.Resolve<AdminAreaSettings>().DefaultGridPageSize;
var gridPageSizes = EngineContext.Current.Resolve<AdminAreaSettings>().GridPageSizes;
//page title
WebViewPage.ViewBag.Title = T("Admin.Affiliates").Text;
//active menu item (system name)
Html.SetActiveMenuItemSystemName("Affiliates");
}
Here's my packages file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="4.4.0" targetFramework="net451" />
<package id="FluentValidation" version="6.4.1" targetFramework="net451" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net451" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net451" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net451" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net451" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
</packages>
On my plugin project, the following libraries are referenced:
Autofac
Autofac.Integration.Mvc
EntityFramework
EntityFramework.SqlServer
FluentValidation
Microsoft.CSharp
Microsoft.Threading.Tasks
Microsoft.Threading.Tasks.Extensions
Microsoft.Threading.Tasks.Extensions.Desktop
Microsoft.Web.Infrastructure
Nop.Admin
Nop.Core
Nop.Data
Nop.Services
Nop.Web
Nop.Web.Framework
System
System.ComponentModel.DataAnnotation
System.Core
System.Data
System.data.DataSetExtensions
System.Net
System.Net.Http
System.Net.Http.Extensions
System.Net.Http.Primitives
System.Web
System.Web.Helpers
System.Web.Mvc
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Xml
System.Xml.Linq
Thank you for any help or guidance. I've also reset my VS settings, cleared its cache.