Program.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.IO;
  2. using Microsoft.AspNetCore.Builder;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.AspNetCore.StaticFiles;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.FileProviders;
  7. using Microsoft.Extensions.Logging;
  8. namespace TestTestTest
  9. {
  10. public class Startup
  11. {
  12. // This method gets called by the runtime. Use this method to add services to the container.
  13. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
  14. public void ConfigureServices(IServiceCollection services)
  15. {
  16. }
  17. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  18. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  19. {
  20. loggerFactory.AddConsole();
  21. if (env.IsDevelopment())
  22. {
  23. app.UseDeveloperExceptionPage();
  24. }
  25. var path = Path.Combine(env.ContentRootPath);
  26. var provider = new PhysicalFileProvider(path);
  27. provider.Watch("*.*");
  28. // Set up custom content types -associating file extension to MIME type
  29. var contentTypeProvider = new FileExtensionContentTypeProvider();
  30. // Add new mappings
  31. contentTypeProvider.Mappings[".hdr"] = "application/octet-stream";
  32. contentTypeProvider.Mappings[".babylon"] = "application/json";
  33. contentTypeProvider.Mappings[".fx"] = "text/plain";
  34. contentTypeProvider.Mappings[".map"] = "text/plain";
  35. var options = new StaticFileOptions()
  36. {
  37. RequestPath = "",
  38. FileProvider = provider,
  39. ContentTypeProvider = contentTypeProvider
  40. };
  41. app.UseStaticFiles(options);
  42. }
  43. }
  44. public class Program
  45. {
  46. public static void Main(string[] args)
  47. {
  48. // PG
  49. var currentDirectory = Directory.GetCurrentDirectory();
  50. // BJS
  51. var babylonjsDirectory = new DirectoryInfo(currentDirectory).Parent.FullName;
  52. var host = new WebHostBuilder()
  53. .UseKestrel()
  54. .UseContentRoot(babylonjsDirectory)
  55. .UseIISIntegration()
  56. .UseStartup<Startup>()
  57. .Build();
  58. host.Run();
  59. }
  60. }
  61. }