webmusic/Startup.cs

43 lines
1.6 KiB
C#
Raw Permalink Normal View History

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
2020-12-21 20:42:29 +01:00
using Microsoft.Extensions.Hosting;
namespace webmusic {
public class Startup {
// This method gets called by the runtime. Use this method to add services to the container.
public static void ConfigureServices(IServiceCollection services) {
services.Configure<CookiePolicyOptions>(options => {
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.Configure<MvcOptions>(options => { options.EnableEndpointRouting = false; });
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
else {
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
2022-11-20 17:55:34 +01:00
var provider = new FileExtensionContentTypeProvider { Mappings = { [".flac"] = "audio/flac", [".m3u"] = "audio/m3u", [".opus"] = "audio/opus" } };
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
2020-12-21 20:42:29 +01:00
app.UseCookiePolicy();
app.UseMvc();
}
}
2022-11-20 17:55:34 +01:00
}