I´m trying to pass a value from a variable var profit = income - expenses
that is inside of an ActionResult on controller.
Does anyone know how is it possible to call this variable on a view? (With a short example please) Or do I need to make a table on purpose to store de value of the variable?
CodePudding user response:
If this is a value that just needs to be available in the view, at this current time you could use ViewData
to handle this.
You could set the value on the Controller
ViewData["Profit"] = profit;
Then you could display that value in the view
@ViewData["Profit"]
There are other options, but this would be the "fastest" route.
Here is a tutorial showing usage of ViewData