mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 04:58:05 +08:00
bca2414491
* modify AntDesign.Docs.Server project to support IE * update docs project * update _Host.cshtml * add .net6 target framework * Update _Host.cshtml * update github actions * update github actions
73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
#if NET5_0_OR_GREATER
|
|
using Blazor.Polyfill.Server;
|
|
#endif
|
|
|
|
namespace AntDesign.Docs.Server
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddRazorPages();
|
|
services.AddServerSideBlazor();
|
|
services.AddTransient(sp => new HttpClient()
|
|
{
|
|
DefaultRequestHeaders =
|
|
{
|
|
// Use to call the github API on server side
|
|
{"User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68"}
|
|
}
|
|
});
|
|
|
|
services.AddAntDesignDocs();
|
|
#if NET5_0_OR_GREATER
|
|
services.AddBlazorPolyfill();
|
|
#endif
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public 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();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
#if NET5_0_OR_GREATER
|
|
app.UseBlazorPolyfill();
|
|
#endif
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapBlazorHub();
|
|
endpoints.MapFallbackToPage("/_Host");
|
|
});
|
|
}
|
|
}
|
|
}
|