source: Farmatiko/Startup.cs@ 822c59d

Last change on this file since 822c59d was 822c59d, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1using Microsoft.AspNetCore.Builder;
2using Microsoft.AspNetCore.Hosting;
3using Microsoft.AspNetCore.HttpsPolicy;
4using Microsoft.AspNetCore.SpaServices.AngularCli;
5using Microsoft.Extensions.Configuration;
6using Microsoft.Extensions.DependencyInjection;
7using Microsoft.Extensions.Hosting;
8
9namespace Farmatiko
10{
11 public class Startup
12 {
13 public Startup(IConfiguration configuration)
14 {
15 Configuration = configuration;
16 }
17
18 public IConfiguration Configuration { get; }
19
20 // This method gets called by the runtime. Use this method to add services to the container.
21 public void ConfigureServices(IServiceCollection services)
22 {
23 services.AddControllersWithViews();
24 // In production, the Angular files will be served from this directory
25 services.AddSpaStaticFiles(configuration =>
26 {
27 configuration.RootPath = "ClientApp/dist";
28 });
29 }
30
31 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
32 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
33 {
34 if (env.IsDevelopment())
35 {
36 app.UseDeveloperExceptionPage();
37 }
38 else
39 {
40 app.UseExceptionHandler("/Error");
41 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
42 app.UseHsts();
43 }
44
45 app.UseHttpsRedirection();
46 app.UseStaticFiles();
47 if (!env.IsDevelopment())
48 {
49 app.UseSpaStaticFiles();
50 }
51
52 app.UseRouting();
53
54 app.UseEndpoints(endpoints =>
55 {
56 endpoints.MapControllerRoute(
57 name: "default",
58 pattern: "{controller}/{action=Index}/{id?}");
59 });
60
61 app.UseSpa(spa =>
62 {
63 // To learn more about options for serving an Angular SPA from ASP.NET Core,
64 // see https://go.microsoft.com/fwlink/?linkid=864501
65
66 spa.Options.SourcePath = "ClientApp";
67
68 if (env.IsDevelopment())
69 {
70 spa.UseAngularCliServer(npmScript: "start");
71 }
72 });
73 }
74 }
75}
Note: See TracBrowser for help on using the repository browser.