I'm trying to pass an object which is a management scope :
ConnectionOptions options = new ConnectionOptions
{
Username = sv.User,
Password = sv.Pass
};
ManagementScope scope = new ManagementScope(@"\\" + sv.Name + @"\root\cimv2", options);
scope.Connect();
return scope;
This is the first controller, basically I'm getting inputs from a form and then connecting to the server with these inputs using the scope which will help me later on to execute commands
public IActionResult Proceed(Server serverModel)
{
if (!ModelState.IsValid) return View("Connect");
else
{
try
{
ManagementScope scope = Connecting.ConnectToServer(serverModel);
return RedirectToAction("Menu", "Schema");
}
catch (Exception e)
{
ViewBag.Message = e.Message.ToString();
return View("Failed");
}
}
}
And this is the second controller , notice that I'm passing the scope as second parameter but that won't work obviously cause scope is unknown
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");
}
}
}
What I have tried:
I tried sending the scope object as TempData and converting it with json but it says that I can't convert ManagementScope Object.