How to read anonymous type in a View MVC .Net Core -


i failing read anonymous type object pass in view, can see values using immediate window ...but when try read object error.

see below visual studio screenshot

enter image description here

please advise ?

passing anonymous types view need casting dynamic types of model when rendering @ view level

at controller :

return view(new {      object1 = "hey there",      object2 = 154.32,      object3 = new emp(84, "test") }) 

at razor view cast object accordingly ,as follows :

@{     string obj1 = (dynamic)model.object1;     decimal obj2= (dynamic)model.object2;     emp obj3= (dynamic)model.object3; } 

now got required stuff @ view anonymous ,play around .


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -