I try to write something like below;
Html.RenderAction("Reviews", "Poetry", new { id = "{{ poetry.ID }}" });
But it gives an error like "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.PartialViewResult"
But if i write something like below it works fine;
var url = Url.Action("Reviews", "Poetry", new { id = "{{ poetry.ID }}" });
How can i pass an angular value in Html.RenderAction method?
Suppose you have controller action like this:
The
RenderActionmethod is parsed and rendered from server before it sent to client's browser, therefore your first approach is not possible because Angular expressions like{{ poetry.ID }}cannot be parsed properly by server-side code as action parameter, hence it passed as null and throwing non-nullable parameter exception sinceiddeclared asint, notNullable<int>.Assumed you want to load partial view using Angular value (or JS value), usually
$http()function is used inside the controller and then call the function name which contains HTTP request:JS variable in Razor
Angular function
Or using shorthanded
$http.get()sinceRenderActionrequires GET method to render partial view contents: