Yes . Specify the full view path in the method View.
public class UserController : Controller
{
public ActionResult ShowUser()
{
return View();
}
}
public class AccountController : Controller
{
public ActionResult ShowAccount()
{
return View("~/Views/User/ShowUser.cshtml");
}
}
If the name of your views is the same for both controllers, you can save the general view in a directory Views/Sharedand simply call the View method without any parameters. The name of the view must be the same as the name of the method Action.
public class UserController : Controller
{
public ActionResult ShowUser()
{
return View();
}
}
public class AccountController : Controller
{
public ActionResult ShowUser()
{
return View();
}
}
Assuming you have a view called ShowUser.cshtmlin a folder Views/Shared.
Shyju source
share