0

I'm trying to go through an anchor (HTML) of the view an object on the page, or I click on the anchor it fills the object and it passes it back to the page and it fills a viewModel, I tried as you see below but it doesn't work, how can I do it?

public async Task<IActionResult>  GetShellysAsync(string button)
{
   shellys = await shellyService.GetShellyAsync("user", "password");
   return RedirectToAction("Settings", "Shelly", shellys);
}

public async Task<IActionResult> Settings()
{
   ViewData["Title"] = "Setting Shelly";
   if(shellys==null)
   {
     shellys = new List<ShellyViewModel>();
     var nd = new ShellyViewModel
     {
        Ip = "NESSUN",
        IdName = "DEVICES"
     };
     shellys.Add(nd);
     return View(shellys);
  }
  return View(shellys);
}

<a asp-action="GetShellysAsync">search</a>
mjwills
  • 23,389
  • 6
  • 40
  • 63
  • `return RedirectToAction("Settings", "Shelly", shellys);` What do the docs say is expected as third parameter there? Is that what you are passing? – mjwills Jul 16 '20 at 07:33
  • @mjwills yes, the third parameter is expected – FRANCESCO RUSSO Jul 16 '20 at 07:45
  • Yes - but what is **expected** as the third parameter? Hint - it isn't what you are passing it. https://learn.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.redirecttoaction?view=aspnet-mvc-5.2#System_Web_Mvc_Controller_RedirectToAction_System_String_System_String_System_Object_ Check the duplicate. – mjwills Jul 16 '20 at 07:45
  • then I didn't know how I should do it – FRANCESCO RUSSO Jul 16 '20 at 07:58

0 Answers0