HomeController.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections.Generic;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Logging;
  4. using System.Linq;
  5. using Library;
  6. namespace MySystem.Controllers
  7. {
  8. public class HomeController : Controller
  9. {
  10. private readonly ILogger<HomeController> _logger;
  11. public HomeController(ILogger<HomeController> logger)
  12. {
  13. _logger = logger;
  14. }
  15. public IActionResult Index()
  16. {
  17. return View();
  18. }
  19. public IActionResult Error()
  20. {
  21. string isapi = Request.Headers["Api"].ToString();
  22. if (isapi != "1")
  23. {
  24. if (Response.StatusCode == 500)
  25. {
  26. return Redirect("/public/errpage/pc/500.html");
  27. }
  28. else if (Response.StatusCode == 502)
  29. {
  30. return Redirect("/public/errpage/pc/502.html");
  31. }
  32. else if (Response.StatusCode == 404)
  33. {
  34. return Redirect("/public/errpage/pc/404.html");
  35. }
  36. }
  37. return View();
  38. }
  39. }
  40. }