Files
ServicesCallService/WebMVC/Controllers/HomeController.cs
2020-10-19 12:55:29 -04:00

46 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using RepositoryLibrary;
using WebMVC.Models;
namespace WebMVC.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IRepository _repository;
public HomeController(ILogger<HomeController> logger, IRepository repository)
{
_logger = logger;
_repository = repository;
}
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> Privacy()
{
// To get this working, I have make a call here in the Privacy page.
// Making the call in the Home/Index page was always returning a 404 Not Found.
// The second project was not starting quickly enough.
var lookup = await _repository.Lookup();
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}