I need to send a parameter of an action to another action on the same controller, but the parameter is "zeroed". How can I do this? Below the code I'm doing:
[Authorize]
public class ItemMaloteController : Controller
{
public IActionResult Index(Guid id)
{
ViewBag.ItemsMaloteList = _itemMaloteRepository.GetAll()
.Where(x => x.MaloteId.Equals(id)).ToList();
ViewBag.Malote = _maloteRepository.GetAll()
.Where(x => x.Id.Equals(id)).ToList();
ViewBag.Curso = _cursoRepository.GetAll().ToList();
ViewBag.Documentos = _documentosRepository.GetAll();
ViewBag.MaloteId = id;
return View();
}
public IActionResult Create(ItemMalote itemMalote)
{
if (!ModelState.IsValid)
return NotFound();
itemMalote.Id = Guid.NewGuid();
_itemMaloteRepository.Register(itemMalote);
_itemMaloteRepository.SaveChanges();
var maloteId = _itemMaloteRepository.GetMalote(itemMalote.MaloteId).Select(x => x.MaloteId).ToList();
//Aqui eu chamo minha action "Index" e passo o parametro
return RedirectToAction("Index", maloteId);
}
}
It happens that when it arrives again in the action "Index" the parameter arrives "zeroed". I have tried to pass through TempData, but the same thing happens.