HomeController.cs
HomeController.cs
is added with another tab Books
by adding the following code:
public IActionResult Books( ) { return RedirectToAction( "Index", "Books" ); }
|
using System.Diagnostics; using BookStore1.Models; using Microsoft.AspNetCore.Mvc; namespace BookStore1.Controllers { public class HomeController : Controller { private readonly ILogger<HomeController> _logger; public HomeController( ILogger<HomeController> logger) { _logger = logger; } public IActionResult Index( ) { return View( ); } public IActionResult Books( ) { return RedirectToAction( "Index", "Books" ); } 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 }); } } } |
RedirectToAction
method is used to redirect the user to a specific action method within a controller.
“I never believed in Santa Claus because I knew no white dude would come into my neighborhood after dark.” — Dick Gregory |