_Layout.cshtml) is as follows:
Index.cshtml, which is the home page:
|
@{ ViewData["Title"] = "Home Page"; }
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">
building Web apps with ASP.NET Core</a>.</p>
</div>
|
Privacy.cshtml:
|
@{ ViewData["Title"] = "Privacy Policy"; }
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>
|
HomeController.cs as follows:
|
using System.Diagnostics;
using HelloWorld.Models;
using Microsoft.AspNetCore.Mvc;
namespace HelloWorld.Controllers {
public class HomeController: Controller {
private readonly ILogger<HomeController> _logger;
public HomeController( ILogger<HomeController> logger ) {
_logger = logger;
}
public IActionResult Index( ) {
return View();
}
public IActionResult Privacy( ) {
return View( );
}
[ResponseCache( Duration = 0, Location = ResponseCacheLocation.None,
NoStore = true )]
public IActionResult Error( ) {
return View( new ErrorViewModel { RequestId = Activity.Current?.Id
?? HttpContext.TraceIdentifier });
}
}
}
|