ASP.Net MVC How to pass url parameters using Html.RenderAction to a ChildAction

The problem here is that

@Html.RenderAction("ContentSection", "Portal", new {sectionAlias = "TermsAndConditions", mvcController = "Portal", mvcAction = "ChoosePayment"})

Is the equivalent to

<%= Html.RenderAction("ContentSection", "Portal", new {sectionAlias = "TermsAndConditions", mvcController = "Portal", mvcAction = "ChoosePayment"}) %>

In the the Webforms ViewEngine (which is also the same a Response.Write). Since RenderAction returns void, you cannot Response.Write it. What you want to do is this:

@{
     Html.RenderAction("ContentSection", "Portal", new {sectionAlias = "TermsAndConditions", mvcController = "Portal", mvcAction = "ChoosePayment"});
 }

The @{ } syntax signifies a code block in the Razor view engine, which would be equivalent to the following the the Webforms ViewEngine:

<% Html.RenderAction("ContentSection", "Portal", new {sectionAlias = "TermsAndConditions", mvcController = "Portal", mvcAction = "ChoosePayment"}); %>

Leave a Comment