2020-10-22 14:59:36 +08:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.IdentityServer.Quickstart.Home
|
|
|
|
|
{
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly IHostEnvironment _environment;
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
2026-06-25 23:42:43 +08:00
|
|
|
public HomeController(IHostEnvironment environment, ILogger<HomeController> logger)
|
2020-10-22 14:59:36 +08:00
|
|
|
{
|
|
|
|
|
_environment = environment;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
if (_environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("Homepage is disabled in production. Returning 404.");
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-06-25 23:42:43 +08:00
|
|
|
/// 显示错误页面
|
2020-10-22 14:59:36 +08:00
|
|
|
/// </summary>
|
2026-06-25 23:42:43 +08:00
|
|
|
public IActionResult Error(string errorId)
|
2020-10-22 14:59:36 +08:00
|
|
|
{
|
2026-06-25 23:42:43 +08:00
|
|
|
var vm = new ErrorViewModel
|
2020-10-22 14:59:36 +08:00
|
|
|
{
|
2026-06-25 23:42:43 +08:00
|
|
|
ErrorId = errorId
|
|
|
|
|
};
|
2020-10-22 14:59:36 +08:00
|
|
|
|
|
|
|
|
return View("Error", vm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|