Redirect to Index View on Button Click in ASP.Net Core MVC

tex
 
on Nov 15, 2021 05:46 AM
395 Views

Hey I need help,

I have controller content Index api and reactivate api in the Index view there list of account with reactivate button when click it call reactivate api, But when finish reactivate i want to back to index view.

public IActionResult Index(string searchText = "")
{
    var _accounts = GetAccounts();
    return View("Index", _accounts);
}

[HttpGet]
public IActionResult Reactivate(string accountNumber)
{
    var _response = reactivate(accountNumber);
    var _accounts = GetAccounts();
    return View("Index", _accounts);
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Nov 15, 2021 06:44 AM

Use RedirectToAction.

return RedirectToAction("Index");