How do I call the proj2's view when the menu item in proj1 is clicked?
Consider using the Razor Class Library (RCL) as "another project (proj2)":
Select [Support pages and views] when creating the RCL project as shown below:
You can add controller, model and view to the RCL:
Below is a sample code of controller in the RCL project:
using Microsoft.AspNetCore.Mvc;
using RazorClassLib.Models;
namespace RazorClassLib.Controllers
{
public class RclController : Controller
{
public IActionResult Index()
{
var model = new RclModel
{
Id = 1,
Name = "Apple",
Price = 100m
};
return View(model);
}
}
}
Add project reference from "main MVC project (Proj1)" to the RCL projects:
Now you can call the controller in the RCL project as shown below: