Guest User

Untitled

a guest
May 22nd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.45 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  6. <meta name="theme-color" content="#000000"><base href="/"/
  7. ><link rel="manifest" href="/manifest.json">
  8. <link rel="shortcut icon" href="/favicon.ico">
  9. <title>nSITE Explorer</title>
  10. <link href="/static/css/main.872a5e7a.css" rel="stylesheet">
  11. <link href="/static/css/main-cssmodules.7f40876c.css" rel="stylesheet">
  12. </head>
  13. <body>
  14. Test
  15. <noscript>You need to enable JavaScript to run this app.</noscript>
  16. <div id="root"></div>
  17. <script type="text/javascript" src="/static/js/main.735c95d1.js"></script>
  18. </body>
  19. </html>
  20.  
  21. <body>
  22. Test
  23. <noscript>You need to enable JavaScript to run this app.</noscript>
  24. <div id="root"></div>
  25. <script type="text/javascript" src="explorer2/ClientApp/build/static/js/main.735c95d1.js"></script>
  26. </body>
  27.  
  28. using Microsoft.AspNetCore.Builder;
  29. using Microsoft.AspNetCore.Hosting;
  30. using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
  31. using Microsoft.Extensions.Configuration;
  32. using Microsoft.Extensions.DependencyInjection;
  33. using System;
  34. using Windsor.Site.Code;
  35. using System.Net;
  36. using Microsoft.AspNetCore.Diagnostics;
  37. using Microsoft.AspNetCore.Http;
  38. using Swashbuckle.AspNetCore.Swagger;
  39. using System.Reflection;
  40. using Windsor.Site.Controllers;
  41. using System.IO;
  42.  
  43. namespace Windsor.Site
  44. {
  45. public class Startup
  46. {
  47. private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Startup));
  48. public IConfiguration Configuration { get; }
  49.  
  50. public Startup(IHostingEnvironment env)
  51. {
  52. var configurationBuilder = new ConfigurationBuilder()
  53. .SetBasePath(Directory.GetCurrentDirectory())
  54. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  55. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  56. .AddEnvironmentVariables();
  57.  
  58. Configuration = configurationBuilder.Build();
  59. // If we want to pull these from the db we can so an ado call right here
  60. }
  61.  
  62.  
  63. // This method gets called by the runtime. Use this method to add services to the container.
  64. public void ConfigureServices(IServiceCollection services)
  65. {
  66. services.AddScoped<IAppSettingsRepository, AppSettingsRepository>();
  67. services.AddScoped<ILayerRepository, LayerRepository>();
  68. services.AddScoped<IProfileRepository, ProfileRepository>();
  69. services.AddScoped<ISiteRepository, SiteRepository>();
  70. services.AddSingleton<IConfiguration>(Configuration);
  71.  
  72. services.AddMvc();
  73.  
  74. services.AddSwaggerGen(c =>
  75. {
  76. c.SwaggerDoc("v1", new Info
  77. {
  78. Version = "v1",
  79. Title = "nSite Explorer API",
  80. Description = "List of API for nSite Explorer"
  81. });
  82. c.IncludeXmlComments(GetXmlCommentsPath());
  83. c.DescribeAllEnumsAsStrings();
  84. });
  85.  
  86. // In production, the React files will be served from this directory
  87. services.AddSpaStaticFiles(configuration =>
  88. {
  89. configuration.RootPath = "ClientApp/build";
  90. });
  91. }
  92.  
  93. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  94. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  95. {
  96. // Should be the first item in Configure so we can catch exceptions from the other items
  97. app.UseExceptionHandler(
  98. options =>
  99. {
  100. options.Run(
  101. async context =>
  102. {
  103. var ex = context.Features.Get<IExceptionHandlerFeature>();
  104. // Log the error
  105. log.Error("An unhandled exception occurred.");
  106. log.Error("Request Path : " + context.Request.Path);
  107. log.Error("Exception Message : " + ex.Error.Message);
  108. if (ex.Error.InnerException != null)
  109. {
  110. log.Error("Inner Exception : " + ex.Error.InnerException.Message);
  111. }
  112. log.Error("Exception Stack Trace : " + ex.Error.StackTrace);
  113.  
  114. // Return the error to the client
  115. context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
  116. context.Response.ContentType = "text/html";
  117.  
  118. if (ex != null)
  119. {
  120. var err = $"<h1>Error: {ex.Error.Message}</h1>";
  121. await context.Response.WriteAsync(err).ConfigureAwait(false);
  122. }
  123. }
  124. );
  125. });
  126.  
  127. // Enable middleware to serve generated Swagger as a JSON endpoint.
  128. app.UseSwagger();
  129. // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
  130. // specifying the Swagger JSON endpoint.
  131. app.UseSwaggerUI(c =>
  132. {
  133. c.SwaggerEndpoint("/swagger/v1/swagger.json", "nSite Explorer API V1");
  134. });
  135.  
  136. app.UseStaticFiles();
  137. app.UseSpaStaticFiles();
  138.  
  139. //app.UseIdentity();
  140.  
  141. app.UseMvc(routes =>
  142. {
  143. routes.MapRoute(
  144. name: "default",
  145. template: "{controller}/{action=Index}/{id?}");
  146. });
  147.  
  148. app.UseSpa(spa =>
  149. {
  150. spa.Options.SourcePath = "ClientApp";
  151.  
  152. if (env.IsDevelopment())
  153. {
  154. spa.UseReactDevelopmentServer(npmScript: "start");
  155. }
  156. });
  157. }
  158. private string GetXmlCommentsPath()
  159. {
  160. var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".xml";
  161. return System.IO.Path.Combine(AppContext.BaseDirectory, commentsFileName);
  162. }
  163. }
  164. }
Add Comment
Please, Sign In to add comment