60 lines
1.6 KiB
C#
Executable File
60 lines
1.6 KiB
C#
Executable File
using Microsoft.AspNetCore;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Rewrite;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System;
|
|
|
|
namespace tononixPC.UpdateServer.Server
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
var host = WebHost.CreateDefaultBuilder(args)
|
|
.UseStartup<Startup>()
|
|
.Build();
|
|
|
|
host.Run();
|
|
}
|
|
}
|
|
|
|
internal class Startup
|
|
{
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
// Adds a default in-memory implementation of IDistributedCache.
|
|
services.AddDistributedMemoryCache();
|
|
|
|
services.AddSession(options =>
|
|
{
|
|
options.IdleTimeout = TimeSpan.FromMinutes(30);
|
|
options.Cookie.HttpOnly = true;
|
|
});
|
|
|
|
services.AddPhp(options =>
|
|
{
|
|
|
|
});
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
app.UseSession();
|
|
// Make the server rewrite to update.php
|
|
var options = new RewriteOptions()
|
|
.AddRewrite(@"^(.*)$", "update.php/$1", skipRemainingRules: true);
|
|
app.UseRewriter(options);
|
|
app.UsePhp();
|
|
app.UseDefaultFiles();
|
|
app.UseStaticFiles();
|
|
}
|
|
}
|
|
}
|