1

So I've been trying to figure out a way to use a Model called Posts in my layout for a few days now, and a solution (that would be perfect if it worked for me) was:

@Html.RenderAction()

Which gave me an error of:

'IHtmlHelper>' does not contain a definition for 'RenderAction' and no extension method 'RenderAction' accepting a first argument of type 'IHtmlHelper>' could be found (are you missing a using directive or an assembly reference?)

I've tried fixing it the error by adding the following to the web.config file, but it doesn't change a thing,

<system.web>
  <pages>
    <namespaces>
      <add namespace="System.Web.Mvc"/>
      <add namespace="System.Web.Mvc.Html"/>
    </namespaces>
  </pages>
</system.web>

trying using System.Web doesn't do anything because the namespace "Web" doesn't exist in "System".

Is there anything I can change to use the Html.RenderAction() method?

Nick
  • 11
  • 3
  • Did you try restarting VS and clean and rebuild? – Guruprasad J Rao Jun 13 '17 at 05:43
  • 2
    `RenderAction` expects at least a string with the action name. https://msdn.microsoft.com/en-us/library/system.web.mvc.html.childactionextensions.renderaction.aspx Are you trying to access a view model in the site's layout? There are other questions about that explaining that that's not possible and also you shouldn't. – Andrew Jun 13 '17 at 05:45
  • If this is not related with how to use `RenderAction` as Andrew said, check for possible symptoms here: https://stackoverflow.com/questions/12041633/razor-views-not-seeing-system-web-mvc-htmlhelper. IIRC `RenderAction` bounds to action name (& controller name) where action executes depending on parameters used. – Tetsuya Yamamoto Jun 13 '17 at 05:56
  • You need to tag your questions correctly. –  Jun 13 '17 at 07:37

0 Answers0