要在ASP.NET Core 2.2 Web应用程序中显示Index.cshtml视图,您需要遵循以下步骤:
在Visual Studio中创建一个新的ASP.NET Core 2.2 Web应用程序项目。
在项目中创建一个名为"HomeController"的控制器。您可以使用以下代码示例:
using Microsoft.AspNetCore.Mvc;
namespace YourAppName.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
}
在项目中创建一个名为"Views/Home"的文件夹。
在"Views/Home"文件夹中创建一个名为"Index.cshtml"的视图文件。
在Index.cshtml中可以添加任何您想要显示的HTML和Razor代码。以下是一个简单的示例:
Welcome to the Index page!
This is the content of the Index page.