0

I am building a website in asp.net core MVC. I have added new area in it. now when i try to use "redirecttoaction" as below:

return RedirectToAction("Index", "testing", new { area = "Employer" }, null);

it is hitting to the action, but view is not loading. not sure what is changed in ASP.NET Core for it. I don't want to hard code the view path like below:

  return View("~/Areas/Employer/Views/testing/Index.cshtml");

Please confirm, what is the right way to achieve this.

Ram Singh
  • 6,664
  • 35
  • 100
  • 166

1 Answers1

0

I found and fixed it. as below:

from here

[Area("Admin")]
[Route("admin")]
public class AdminController : Controller
{
public AdminController()
{
    // do stuff
}

public IActionResult Index()
{
    return View();
}

[Route("[action]/{page:int?}")]
public IActionResult Orders()
{
    return View();
}

[Route("[action]")]
public IActionResult Shop()
{
    return View();
}

[Route("[action]/newest")]
public IActionResult Payments()
{
    return View();
 }
}

Happy Coding. :)

Ram Singh
  • 6,664
  • 35
  • 100
  • 166