When playing with the Razor syntax for view creation in Asp.net MVC you need to remember its not quite a direct translation between it and the web forms view engine and it is a different syntax. I was frustrated by it earlier in the week and without internet connection continued couldn’t resolve it instantly. It comes down to the syntactic sugar which Razor gives you.
When it comes to methods on the Html helper you can’t use the syntactic sugar by itself you do need to give Razor some parentheses.
Web forms view engine:
<% Html.RenderAction("About"); %>
Razor view engine:
@{ Html.RenderAction("About"); }
not @Html.RenderAction("About")
1 comment:
Thanks for this short and informative post. I was scratching my head over this.
Post a Comment