I have an object called scope that allows me to connect to a server. I want to keep that object throughout all the procedure so I need to pass it to another controller. This is the connect to server controller :
public IActionResult Proceed(Server serverModel)
{
if (!ModelState.IsValid) return View("Connect");
else
{
try
{
// --------- This is what I need to save ------------ \\
ManagementScope scope = Connecting.ConnectToServer(serverModel);
// --------- This is what I need to save ------------ \\
return RedirectToAction("Menu", "Schema");
}
catch (Exception e)
{
ViewBag.Message = e.Message.ToString();
return View("Failed");
}
}
}
and in the other controller I need to pass it as a parameter :
public IActionResult ExportProceed(SchemaExport ex)
{
if (!ModelState.IsValid) return View("Export");
else
{
try
{
ExportProcess.CreateDirectories(ex, scope);
return RedirectToAction("Menu", "Schema");
}
catch (Exception e)
{
ViewBag.Message = e.Message.ToString();
return View("Failed");
}
}
}