Add two numbers
Add two numbers
Let us add 2 numbers using mvc architecture. We could do this in a separate controller or in the existing home controller like shown below
Controller Code
View Code
In ASP.NET Core MVC, there are three ways to pass data from a controller to a view:
using
ViewData
,using
ViewBag
, andusing strongly-typed models.
ViewData
and ViewBag
are similar in that they are both dictionaries that can be used to pass data from a controller to a view. However, they differ in their syntax. Since its introduction, ViewBag
has become a popular choice for passing data between the controller and the view, due to its simplicity and ease of use.
Last updated