The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DefaultController.cs 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.Extensions.Logging;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. using Teknik.Configuration;
  11. using Teknik.Logging;
  12. using Teknik.Utilities;
  13. namespace Teknik.IdentityServer.Controllers
  14. {
  15. public class DefaultController : Controller
  16. {
  17. protected readonly ILogger<Logger> _logger;
  18. protected readonly Config _config;
  19. public DefaultController(ILogger<Logger> logger, Config config)
  20. {
  21. _logger = logger;
  22. _config = config;
  23. ViewBag.Title = string.Empty;
  24. ViewBag.Description = "Teknik Authentication Service";
  25. }
  26. // Get the Favicon
  27. [HttpGet]
  28. [AllowAnonymous]
  29. [ResponseCache(Duration = 31536000, Location = ResponseCacheLocation.Any)]
  30. public IActionResult Favicon([FromServices] IHostingEnvironment env)
  31. {
  32. string imageFile = FileHelper.MapPath(env, Constants.FAVICON_PATH);
  33. FileStream fs = new FileStream(imageFile, FileMode.Open, FileAccess.Read);
  34. return File(fs, "image/x-icon");
  35. }
  36. // Get the Robots.txt
  37. [HttpGet]
  38. [AllowAnonymous]
  39. public IActionResult Robots([FromServices] IHostingEnvironment env)
  40. {
  41. //string file = FileHelper.MapPath(env, Constants.ROBOTS_PATH);
  42. return File(Constants.ROBOTS_PATH, "text/plain");
  43. }
  44. protected IActionResult GenerateActionResult(object json)
  45. {
  46. return GenerateActionResult(json, View());
  47. }
  48. protected IActionResult GenerateActionResult(object json, IActionResult result)
  49. {
  50. if (Request.IsAjaxRequest())
  51. {
  52. return Json(json);
  53. }
  54. return result;
  55. }
  56. }
  57. }