I would like to calculate the time it takes for the method to run so I am trying to pass the start time, end time and elapsed time value to the view from the controller. How can I do that?
This is a controller that I am already using to pass value from a cs file so the ViewBag.Message is for that but I want to use another one to pass more values to the view.
public ActionResult Test()
{
var startTime = DateTime.Now;
ViewBag.Message = _importFactory.importScanSourceProductData(CurrentTenantId, "", null, CurrentUserId);
var endTime = DateTime.Now;
var elapsedTime = endTime - startTime;
ViewBag.Message = elapsedTime;
return View();
}
View
@model dynamic
@{
Layout = null;
var data = ViewBag.Message;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Test</title>
</head>
<body>
<div>
<h1>Import Scan Source Product Data</h1>
<p>@data</p>
</div>
</body>
</html>