I am trying to include some reusable code throughout my website (not web application) via the RenderPartial call @Html.RenderPartial("SomePage.cshtml"). In asp I was just able to use #include virtual="somefile.asp". However, I receive the following error message.
Compiler Error Message: CS1061: 'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I have include all the appropriate references in my web.config file.
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Collections.Generic"/>
</namespaces>
</pages>
Is the RenderPartial only available in "Web Applications" and not "Websites"?
Is there a better way to reuse code throughout the site?
@RenderSection does not work in my situation since the layout I'm using does not reuse the code in the same location.
Web.config
the one located in theViews
directory? – Buildstarted